Skip to content

Commit 3ef324b

Browse files
authored
ls test
1 parent bd8d5e5 commit 3ef324b

3 files changed

Lines changed: 299 additions & 162 deletions

File tree

.github/workflows/Build-Kernel.yml

Lines changed: 87 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Build Kernel
1+
name: Build Kernel 2.0
22

33
on:
4-
schedule:
5-
- cron: '52 */3 * * *'
4+
# schedule:
5+
# - cron: '52 */3 * * *'
66
workflow_dispatch:
77
inputs:
88
debug_enabled:
@@ -19,188 +19,114 @@ on:
1919
- "Artifact"
2020
- "Release"
2121

22+
## CONFIG ##############################################################################
2223
jobs:
23-
build:
24+
job-config:
2425
runs-on: ubuntu-latest
25-
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
26+
outputs:
27+
matrix: ${{ steps.set-matrix.outputs.matrix }}
28+
cancel: ${{ steps.prebuild-checks.outputs.cancel }}
2629
defaults:
2730
run:
2831
shell: bash
2932
steps:
30-
- name: "✔️ Pre-build checks"
33+
- name: "PRE-BUILD CHECKS"
34+
id: prebuild-checks
3135
run: |
32-
body="/home/runner/body.txt"
33-
jsonFile="/home/runner/kernels.json"
34-
WSL_DATE="$(wget -q -O- https://api.github.com/repos/microsoft/WSL2-Linux-Kernel/commits | jq '.[1].commit.committer.date' -r )"
35-
LAST_DATE="$( wget -q -O- https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest | jq .published_at -r )" || LAST_DATE="2000.01.01T00:00:00Z"
36-
echo "The last WSL2 Kernel commit date is: $WSL_DATE"
37-
echo "The last Release in this repo was on: $LAST_DATE"
38-
if [[ $WSL_DATE > $LAST_DATE ]]; then
39-
echo "NEW KERNEL SOURCE!!!!"
40-
echo "# KERNEL UPDATES" > $body
41-
echo >> $body
42-
wget -q -O- https://api.github.com/repos/microsoft/WSL2-Linux-Kernel/releases/latest | jq .body -r >> $body
43-
fi
44-
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
45-
echo "NEW IMPROVEMENT!!!!"
46-
[ -f $body ] && echo >> $body
47-
echo "# IMPROVEMENTS" >> $body
48-
echo >> $body
49-
50-
fi
51-
if [ -f $body ]; then
52-
echo "CANCEL=false" >> $GITHUB_ENV
53-
echo "{}" | jq "\
54-
.commitDate |= \"${WSL_DATE}\" |\
55-
.buildDate |= \"$(TZ=UTC date +'%Y.%m.%dT%H:%M:%SZ')\"" > $jsonFile
56-
57-
else
58-
echo "NOTHING NEW. CANCELLING ACTION..."
59-
echo "CANCEL=true" >> $GITHUB_ENV
60-
fi
36+
echo "cancel=false" >> $GITHUB_OUTPUT
6137
6238
6339
- name: "⏬ Checkout repository"
64-
if: env.CANCEL != 'true'
40+
if: ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
6541
uses: actions/checkout@v3
6642

6743

68-
- name: "🔧 Prepare debug session"
69-
if: github.event.inputs.debug_enabled == 'true'
70-
run: |
71-
## install zsh
72-
sudo apt install zsh zsh-syntax-highlighting
73-
74-
## oh-my-posh
75-
sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
76-
sudo chmod +x /usr/local/bin/oh-my-posh
77-
78-
## setting rc files
79-
echo "eval \"\$(oh-my-posh init \$(oh-my-posh get shell))\"" >> ~/.bashrc
80-
echo "eval \"\$(oh-my-posh init \$(oh-my-posh get shell))\"" >> ~/.zshrc
81-
82-
## Default profiles
83-
wget -q https://github.com/okibcn/miniU/raw/main/Github_Linux/.nanorc -O ~/.nanorc
84-
wget -q https://github.com/okibcn/miniU/raw/main/Github_Linux/profile.sh -O ~/profile.sh
85-
cp /etc/bash.bashrc ~
86-
cat ~/profile.sh >> ~/bash.bashrc
87-
sudo cp ~/bash.bashrc /etc/bash.bashrc -f
88-
cp ~/profile.sh ~/.zshrc
89-
90-
91-
- name: "🐞 Debug session"
92-
uses: mxschmitt/action-tmate@v3
93-
if: github.event.inputs.debug_enabled == 'true'
94-
env:
95-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96-
## More info at https://til.simonwillison.net/github-actions/debug-tmate
97-
## or https://github.com/mxschmitt/action-tmate
98-
99-
100-
- name: "⏬ Install Toolchain OS Tools"
101-
if: env.CANCEL != 'true'
102-
run: sudo apt -y install build-essential flex bison dwarves libssl-dev libelf-dev python3 bc jq aria2 p7zip-full
103-
104-
105-
- name: "⏬ Fetch latest WSL kernel source"
106-
if: env.CANCEL != 'true'
44+
- name: "DETECT CONFIGS"
45+
id: set-matrix
46+
if: ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
47+
shell: pwsh
10748
run: |
108-
## Slowwwww....
109-
git clone --depth=1 https://github.com/microsoft/WSL2-Linux-Kernel.git kernel
110-
111-
## FAST!!!
112-
aria2c -x 8 -j 8 -s 8 https://api.github.com/repos/microsoft/WSL2-Linux-Kernel/zipball -ozipball.zip
113-
# 7z x zipball.zip -otemp
114-
# mkdir -p kernel
115-
# mv temp/*/{*,.[^\.]*} kernel
116-
# rm -rf zipball.zip temp
117-
118-
# Update json
119-
cd kernel
120-
mv /home/runner/kernels.json .
121-
json=$(jq ".version |= \"$(make kernelversion)\"" kernels.json)
122-
echo "$json" > kernels.json
123-
124-
125-
- name: "⚙️ Build WSL2 Kernel for Windows 64 bits"
126-
if: env.CANCEL != 'true'
127-
run: |
128-
cd kernel
129-
cp Microsoft/config-wsl .config
130-
yes '' | make -j$(($(nproc)*2+1)) || true
131-
cp arch/x86/boot/bzImage WSL2kernel_std
132-
133-
# Update json
134-
json=$(jq '.kernels |= . + [{ "config": "std",
135-
"description": "Standard Microsoft WSL2 kernel" }]' kernels.json)
136-
echo $json > kernels.json
49+
$m=@{include = @()}
50+
(gci *.dif).baseName | % { $m.include+=@{config = $_} }
51+
"MATRIX:"
52+
$m | ConvertTo-Json
53+
"MATRIX STRING:"
54+
"matrix=$(($m | ConvertTo-Json -compress) -replace '"','`"')"
55+
"matrix=$(($m | ConvertTo-Json -compress) -replace '"','`"')" >> $env:GITHUB_OUTPUT
13756
13857
139-
- name: "⚙️ Build WSL2 Kernel with NBD for Windows 64 bits"
140-
if: env.CANCEL != 'true'
58+
- name: "✔️ TEST matrix"
59+
if: ${{ steps.prebuild-checks.outputs.cancel }} != 'true'
14160
run: |
142-
## NOTE: dif file generated after `makeconfig nconfig` with instruction:
143-
# diff -u Microsoft/config-wsl .config | grep "^[+-][^+^-].*" > ../name.dif
144-
difFile=../nbd.dif
145-
cd kernel
146-
make distclean
147-
cp Microsoft/config-wsl .config
148-
sed -i "s/-standard-/-nbd-/" .config
149-
while read line; do
150-
case ${line:0:1} in
151-
+) echo "adding : ${line:1}"
152-
echo ${line:1} >> .config ;;
153-
-) echo "removing: ${line:1}"
154-
sed -i "/${line:1}/d" .config ;;
155-
esac
156-
done < $difFile
157-
yes '' | make -j$(($(nproc)*2+1)) || true
158-
cp arch/x86/boot/bzImage WSL2kernel_nbd
61+
echo "MATRIX:"
62+
echo ${{ steps.set-matrix.outputs.matrix }}
63+
echo "CANCEL:"
64+
echo ${{ steps.prebuild-checks.outputs.cancel }}
15965
160-
# Update json
161-
json=$(jq '.kernels |= . + [{ "config": "nbd",
162-
"description": "Network Block Device enabled WSL2 kernel" }]' kernels.json)
163-
echo $json > kernels.json
16466
165-
166-
- name: "📦 Create Package"
167-
if: env.CANCEL != 'true'
67+
## BUILD ##############################################################################
68+
job-build:
69+
needs: [ job-config ]
70+
if: ${{ needs.job-config.outputs.cancel }} != 'true'
71+
name: "Build configuration ${{ matrix.config }}"
72+
runs-on: ubuntu-latest
73+
strategy:
74+
matrix: ${{ FromJson(needs.job-config.outputs.matrix) }}
75+
# config: ${{ FromJson(needs.job-config.outputs.configs) }}
76+
fail-fast: false
77+
defaults:
78+
run:
79+
shell: bash
80+
steps:
81+
- name: "✔️ TEST matrix"
16882
run: |
169-
############################
170-
## ##
171-
## CREATE PACKAGE ##
172-
## ##
173-
############################
174-
cd kernel
175-
APP_VERSION=$(cat ../wsl2kernel.ps1 | grep -Po "^#.*v([\d\.\-]+)" | grep -Po "([\d\.\-]+)")
176-
KERNEL_VERSION=$(make kernelversion)
177-
echo "VERSION=${KERNEL_VERSION}-${APP_VERSION}" >> $GITHUB_ENV
178-
cp ../*.ps1 .
179-
find . -name "WSL2k*" | while read file; do
180-
mv "$file" "${file}_${KERNEL_VERSION}"
181-
done
182-
7z a -aoa -tzip -- "../WSL2kernel_${KERNEL_VERSION}.zip" kernels.json *.ps1 WSL2k*
183-
83+
echo "MATRIX:"
84+
echo ${{ needs.job-config.outputs.matrix }}
85+
echo "CONFIG:"
86+
echo ${{ matrix.config }}
87+
echo "CANCEL:"
88+
echo ${{ needs.job-config.outputs.cancel }}
89+
echo "${{ matrix.config }}" >> WSL2kernel
18490
18591
- name: "👍 Upload Artifact"
18692
uses: actions/upload-artifact@v3
187-
if: env.CANCEL != 'true' && github.event.inputs.release == 'Artifact'
18893
with:
189-
name: ${{ env.VERSION }}
94+
name: ${{ matrix.config }}
19095
path: |
191-
*.zip
192-
193-
194-
- name: "🎉 Publish a new release"
195-
uses: softprops/action-gh-release@v0.1.15
196-
# WARNING: before useing this action go to https://github.com/OWNER/REPO/settings/actions
197-
# and in **Workflow Permissions** section give actions **Read and Write permissions**.
198-
if: env.CANCEL != 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.release == 'Release')
199-
env:
200-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
WSL2kernel
97+
98+
## PUBLISH ##############################################################################
99+
job-publish:
100+
if: ${{ needs.job-config.outputs.cancel }} != 'true'
101+
needs:
102+
- job-config
103+
- job-build
104+
name: "Publish"
105+
runs-on: ubuntu-latest
106+
defaults:
107+
run:
108+
shell: bash
109+
steps:
110+
- name: "✔️ TEST matrix"
111+
run: |
112+
echo "MATRIX:"
113+
echo '${{ needs.job-config.outputs.matrix }}'
114+
echo '${{ needs.job-config.outputs.matrix }}' | jq . || true
115+
echo "CANCEL:"
116+
echo ${{ needs.job-config.outputs.cancel }}
117+
118+
- name: Artifact downloader
119+
uses: actions/download-artifact@v3
201120
with:
202-
tag_name: ${{ env.VERSION }}
203-
body_path: /home/runner/body.txt
204-
files: |
205-
*.zip
121+
path: ~/artifacts
206122

123+
- name: Delete Artifacts
124+
uses: jimschubert/delete-artifacts-action@v1
125+
126+
- name: "✔️ TEST matrix"
127+
run: |
128+
pwd
129+
ls -als $(pwd)
130+
ls -als ~
131+
ls -Rals ~/artifacts
132+

0 commit comments

Comments
 (0)