3434 id : prebuild-checks
3535 run : |
3636 body="$(pwd)/body.txt"
37- jsonFile="/home/runner /kernels.json"
37+ jsonFile="$(pwd) /kernels.json"
3838 WSL_DATE="$( wget -qO- https://api.github.com/repos/microsoft/WSL2-Linux-Kernel/commits | jq '.[1].commit.committer.date' -r )"
3939 LAST_DATE="$( wget -qO- https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq .published_at -r )" || LAST_DATE="2000.01.01T00:00:00Z"
4040 echo "The last WSL2 Kernel commit date is: $WSL_DATE"
@@ -65,57 +65,36 @@ jobs:
6565 if : ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
6666 uses : actions/checkout@v3
6767
68- - name : " ⏬ Download and Install Toolchain"
69- if : ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
70- run : sudo apt -y install build-essential flex bison dwarves libssl-dev libelf-dev python3 bc jq aria2 p7zip-full
71-
7268 - name : " ⏬ Fetch latest WSL kernel source"
7369 if : ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
74- run : git clone --depth=1 https://github.com/microsoft/WSL2-Linux-Kernel.git kernel
70+ run : git clone --depth=1 https://github.com/microsoft/WSL2-Linux-Kernel.git src
7571
76- - name : " 🔍 Detect Configurations "
72+ - name : " 🪄 Prepare Build jobs "
7773 id : set-matrix
7874 if : ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
7975 shell : pwsh
8076 run : |
77+ jq ".version |= \`"$(cd src;make kernelversion;cd ..)\`"" kernels.json | set-content kernels.json
78+ 7z a metadata.7z body.txt kernels.json
8179 $m=@{include = @()}
8280 (gci *.dif).baseName | % { $m.include+=@{config = $_} }
8381 "matrix=$(($m | ConvertTo-Json -compress) -replace '"','`"')" >> $env:GITHUB_OUTPUT
8482
85- - name : " 📨 Send repo to jobs"
83+ - name : " 💾 Save metadata"
84+ if : ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
8685 uses : actions/cache@v3.2.6
87- id : cache-sources
86+ id : cache-metadata
8887 with :
89- path : ./*
90- key : ${{ github.sha }}-repo
88+ key : ${{ github.sha }}-metadata
89+ path : ./metadata.7z
9190
92- - name : " 📨 Send release body"
91+ - name : " 💾 Save Build Folder"
92+ if : ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
9393 uses : actions/cache@v3.2.6
94- id : cache-body
94+ id : cache-sources
9595 with :
96- path : ./body.txt
97- key : ${{ github.sha }}-body
98-
99- - name : " 🔧 Prepare debug session"
100- if : github.event.inputs.debug_enabled == 'true'
101- run : |
102- sudo apt -y install zsh zsh-syntax-highlighting
103- sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
104- sudo chmod +x /usr/local/bin/oh-my-posh
105- wget -q https://github.com/okibcn/miniU/raw/main/Github_Linux/.nanorc -O ~/.nanorc
106- wget -q https://github.com/okibcn/miniU/raw/main/Github_Linux/profile.sh -O ~/profile.sh
107- cp /etc/bash.bashrc ~
108- cat ~/profile.sh >> ~/bash.bashrc
109- sudo cp ~/bash.bashrc /etc/bash.bashrc -f
110- cp ~/profile.sh ~/.zshrc
111-
112- - name : " 🐞 Debug session"
113- uses : mxschmitt/action-tmate@v3
114- if : github.event.inputs.debug_enabled == 'true'
115- env :
116- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
117- # # More info at https://til.simonwillison.net/github-actions/debug-tmate
118- # # or https://github.com/mxschmitt/action-tmate
96+ path : ./*
97+ key : ${{ github.sha }}-repo
11998
12099 # # BUILD ##############################################################################
121100 job-build :
@@ -131,22 +110,42 @@ jobs:
131110 run :
132111 shell : bash
133112 steps :
134- - name : " ✔️ TEST matrix"
135- run : |
136- echo "MATRIX:"
137- echo ${{ needs.job-config.outputs.matrix }}
138- echo "CONFIG:"
139- echo ${{ matrix.config }}
140- echo "CANCEL:"
141- echo ${{ needs.job-config.outputs.cancel }}
142- echo "${{ matrix.config }}" >> WSL2kernel
113+ - name : " ⏬ Download and Install Toolchain"
114+ if : ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
115+ run : sudo apt -y install build-essential flex bison dwarves libssl-dev libelf-dev python3 bc jq aria2 p7zip-full
143116
144- - name : " 👍 Upload Artifact"
117+ - name : " 📂 Load Build Folder"
118+ uses : actions/cache@v3.2.6
119+ id : cache-sources
120+ with :
121+ path : ./*
122+ key : ${{ github.sha }}-repo
123+
124+ - name : " ⚙️ Build WSL2 Kernel with ${{ matrix.config }} configuration for Windows 64 bits"
125+ run : |
126+ ## NOTE: dif file generated after `makeconfig nconfig` with instruction:
127+ # diff -u Microsoft/config-wsl .config | grep "^[+-][^+^-].*" > ../<CONFIG>.dif
128+ difFile="$(pwd)/${{ matrix.config }}.dif"
129+ cd src
130+ sed "s/-standard-/-${{ matrix.config }}-/" Microsoft/config-wsl > .config
131+ while read line; do
132+ case ${line:0:1} in
133+ +) echo "adding : ${line:1}"
134+ echo ${line:1} >> .config ;;
135+ -) echo "removing: ${line:1}"
136+ sed -i "/${line:1}/d" .config ;;
137+ esac
138+ done < $difFile
139+ yes '' | make -j$(($(nproc)*2+1)) || true
140+ cp arch/x86/boot/bzImage ../WSL2kernel_${{ matrix.config }}
141+
142+ - name : " 👍 Upload Image as Artifact"
145143 uses : actions/upload-artifact@v3
146144 with :
147145 name : ${{ matrix.config }}
148146 path : |
149- WSL2kernel
147+ WSL2kernel_${{ matrix.config }}
148+ src/.config
150149
151150 # # PUBLISH ##############################################################################
152151 job-publish :
@@ -160,26 +159,13 @@ jobs:
160159 run :
161160 shell : bash
162161 steps :
163- - name : " ✔️ TEST matrix"
164- run : |
165- echo "MATRIX:"
166- echo '${{ needs.job-config.outputs.matrix }}'
167- echo '${{ needs.job-config.outputs.matrix }}' | jq . || true
168- echo "CANCEL:"
169- echo ${{ needs.job-config.outputs.cancel }}
170-
171- - name : Artifact downloader
162+ - name : " 📬 Receive Images from Build Jobs"
172163 uses : actions/download-artifact@v3
173164 with :
174- path : ~ /artifacts
165+ path : . /artifacts
175166
176- - name : Delete Artifacts
177- uses : jimschubert/delete-artifacts-action@v1
167+ - uses : geekyeggo/delete-artifact@v2
168+ with :
169+ name : ' *'
178170
179- - name : " ✔️ TEST matrix"
180- run : |
181- pwd
182- ls -als $(pwd)
183- ls -als ~
184- ls -Rals ~/artifacts
185-
171+ - uses : snnaplab/delete-branch-cache-action@v1
0 commit comments