Repository navigation
381 lines (339 loc) · 14.2 KB
/
Copy pathkernel-update.yml
File metadata and controls
381 lines (339 loc) · 14.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
name: Update kernels
run-name: Kernel ${{ inputs.mode }} ${{ inputs.archpkg }}
# Started by kernel-watch.yml when Arch's linux moves within the series (update) or a newer one waits in
# core-testing (check), and by hand the same way. The fork branches are rebased onto Arch's new tag and the
# recipes take Arch's new config; both kernels are built and boot-tested; only then does an update push the
# fork branches and tags, publish the packages and commit the recipes. A check stops after the boot test.
# The nvidia mode moves only the NVIDIA module pins of the kernels that build them, when extra's nvidia-utils
# or [mainstream]'s nvidia-580xx-utils moves, and builds, boots and publishes those kernels the same way.
# Any failure opens an issue for that Arch version and stage instead (scripts/kernel-issue.py).
on:
workflow_dispatch:
inputs:
mode:
description: 'update: build, boot-test and publish; check: build and boot-test only; nvidia: move the NVIDIA module pins, then as update'
type: choice
options: [update, check, nvidia]
default: update
archpkg:
description: "Arch's linux package to move to, for example 7.3.6.arch1-1; for nvidia, <open>+<580xx>, for example 620.73.04+580.196.07"
required: true
permissions: {}
# Shared with kernels.yml, so two kernel runs never build at once; publishing also takes build.yml's group.
concurrency:
group: build-mainstream-kernels
cancel-in-progress: false
jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 90
permissions:
contents: read
container:
image: archlinux:base-devel
outputs:
kind: ${{ steps.prepare.outputs.kind }}
base: ${{ steps.prepare.outputs.base }}
kernels: ${{ steps.plan.outputs.kernels }}
steps:
- name: Install tooling
run: pacman -Syu --noconfirm git github-cli python
- uses: actions/checkout@v6
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- name: Create build user
run: |
useradd -m builder
chown -R builder:builder "$GITHUB_WORKSPACE"
- name: Rebase the fork and update the recipes
id: prepare
env:
ARCHPKG: ${{ inputs.archpkg }}
MODE: ${{ inputs.mode }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
set -o pipefail
echo "base=$(runuser -u builder -- git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
command=prepare
[ "$MODE" != nvidia ] || command=nvidia
runuser -u builder -- env OUT="$GITHUB_WORKSPACE/prepared" GITHUB_REPOSITORY="$GITHUB_REPOSITORY" \
bash scripts/kernel-update.sh "$command" "$ARCHPKG" 2>&1 | tee prepare.log
. prepared/update.env
echo "kind=$KIND" >> "$GITHUB_OUTPUT"
if [ -f prepared/summary.md ]; then cat prepared/summary.md >> "$GITHUB_STEP_SUMMARY"; fi
- name: Pick the kernels that are not published at the new version
id: plan
if: steps.prepare.outputs.kind != 'none'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -o pipefail
runuser -u builder -- env GH_TOKEN="$GH_TOKEN" GITHUB_REPOSITORY="$GITHUB_REPOSITORY" \
python scripts/repo_safety.py snapshot "$GITHUB_WORKSPACE/published-assets.json"
kernels=$(runuser -u builder -- env PUBLISHED_ASSETS="$GITHUB_WORKSPACE/published-assets.json" \
bash build-kernel.sh plan)
echo "kernels=$kernels" >> "$GITHUB_OUTPUT"
echo "Kernels to build: $kernels" >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@v4
if: steps.prepare.outputs.kind != 'none'
with:
name: prepared
path: |
prepared/update.env
prepared/recipes.patch
prepared/summary.md
prepared/src/*.tar.gz
prepared/fork.bundle
if-no-files-found: error
compression-level: 0
retention-days: 14
- name: Keep the failure for the issue
if: failure()
run: |
mkdir -p failure
if [ -f prepared/failure.md ]; then
cp prepared/failure.md failure/failure.md
else
{ echo "stage: prepare"; echo; echo '```'; tail -n 60 prepare.log 2>/dev/null; echo '```'; } > failure/failure.md
fi
- uses: actions/upload-artifact@v4
if: failure()
with:
name: failure-prepare
path: failure/failure.md
build:
needs: prepare
if: needs.prepare.outputs.kind != 'none' && needs.prepare.outputs.kernels != '[]'
# Same runner set-up as kernels.yml: the host frees its disk, the Arch container builds and boots.
runs-on: ubuntu-latest
timeout-minutes: 340
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.prepare.outputs.kernels) }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.base }}
persist-credentials: false
- uses: actions/download-artifact@v4
with:
name: prepared
path: prepared
- uses: ./.github/actions/kernel-runner
- name: Apply the recipe update
run: docker exec arch runuser -u builder -- git apply prepared/recipes.patch
- name: Import signing key
if: inputs.mode != 'check'
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
run: |
docker exec -e GPG_PRIVATE_KEY -e GPG_KEY_ID arch bash -c '
install -d -m700 -o builder -g builder /home/builder/.gnupg
printf "%s" "$GPG_PRIVATE_KEY" | runuser -u builder -- gpg --batch --import
printf "5\ny\n" | runuser -u builder -- gpg --batch --command-fd 0 --edit-key "$GPG_KEY_ID" trust quit'
- name: Snapshot published package filenames
env:
GH_TOKEN: ${{ github.token }}
run: |
docker exec -e GH_TOKEN -e GITHUB_REPOSITORY arch runuser -u builder -- \
python scripts/repo_safety.py snapshot "$GITHUB_WORKSPACE/published-assets.json"
- name: Build ${{ matrix.kernel }}
id: build
# Only a signed entry is given the Secure Boot signer, whose certificate the repository carries.
uses: ./.github/actions/kernel-runner/build
with:
kernel: ${{ matrix.kernel }}
signed: ${{ matrix.signed }}
signer-key: ${{ matrix.signed && secrets.EAC_SIGNER_KEY || '' }}
gpg-key: ${{ inputs.mode != 'check' && secrets.GPG_KEY_ID || '' }}
src-dir: prepared/src
log: build.log
- name: Boot ${{ matrix.kernel }}
id: boot
if: matrix.boot
run: |
set -o pipefail
docker exec arch runuser -u builder -- bash scripts/boot-test-kernel.sh --built out "${{ matrix.kernel }}" 2>&1 | tee boot.log
- uses: actions/upload-artifact@v4
if: inputs.mode != 'check'
with:
name: kernel-${{ matrix.kernel }}
path: |
out/*.pkg.tar.zst
out/*.pkg.tar.zst.sig
if-no-files-found: error
retention-days: 14
- name: Keep the failure for the issue
if: failure()
env:
KERNEL: ${{ matrix.kernel }}
BUILD: ${{ steps.build.outcome }}
BOOT: ${{ steps.boot.outcome }}
run: |
mkdir -p failure
if [ "$BUILD" = failure ]; then stage="build $KERNEL" log=build.log
elif [ "$BOOT" = failure ]; then stage="boot $KERNEL" log=boot.log
else stage="build $KERNEL" log=/dev/null; fi
{ echo "stage: $stage"; echo; echo "Last lines of the log:"; echo '```'
tail -n 60 "$log" 2>/dev/null; echo '```'; } > failure/failure.md
- uses: actions/upload-artifact@v4
if: failure()
with:
name: failure-build-${{ matrix.kernel }}
path: failure/failure.md
publish:
needs: [prepare, build]
if: >-
always() && inputs.mode != 'check' && needs.prepare.result == 'success'
&& needs.prepare.outputs.kind != 'none'
&& (needs.build.result == 'success' || needs.build.result == 'skipped')
runs-on: ubuntu-latest
timeout-minutes: 120
# The owner can add a required reviewer to this environment to approve each publish.
environment: kernel-publish
permissions:
contents: write # release assets and the recipe commit
# Same group as build.yml, so the database is never written by two runs at once.
concurrency:
group: build-mainstream-repo
cancel-in-progress: false
container:
image: archlinux:base-devel
steps:
- name: Install tooling
run: pacman -Syu --noconfirm git gnupg github-cli rsync openssh python
- uses: actions/checkout@v6
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@v4
with:
name: prepared
path: prepared
- uses: actions/download-artifact@v4
with:
pattern: kernel-*
path: out
merge-multiple: true
- name: Create build user
run: |
useradd -m builder
chown -R builder:builder "$GITHUB_WORKSPACE"
runuser -u builder -- git apply prepared/recipes.patch
- name: Push the fork branches and tags
env:
KERNEL_FORK_TOKEN: ${{ secrets.KERNEL_FORK_TOKEN }}
run: |
set -o pipefail
runuser -u builder -- env OUT="$GITHUB_WORKSPACE/prepared" KERNEL_FORK_TOKEN="$KERNEL_FORK_TOKEN" \
bash scripts/kernel-update.sh push 2>&1 | tee publish.log
- name: Check for built kernels
id: built
run: |
shopt -s nullglob
pkgs=(out/*.pkg.tar.zst)
echo "count=${#pkgs[@]}" >> "$GITHUB_OUTPUT"
[ ${#pkgs[@]} -gt 0 ] || echo "The kernels were already published; only the recipes are committed." >> "$GITHUB_STEP_SUMMARY"
- name: Import signing key
if: steps.built.outputs.count != '0'
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
install -d -m700 -o builder -g builder /home/builder/.gnupg
printf '%s' "$GPG_PRIVATE_KEY" | runuser -u builder -- gpg --batch --import
runuser -u builder -- bash -c \
"gpg --batch --command-fd 0 --edit-key '${{ secrets.GPG_KEY_ID }}' trust quit <<<'5
y'"
- name: Snapshot published package filenames
# Taken here, inside the shared group: build.yml may have published since the plan.
if: steps.built.outputs.count != '0'
env:
GH_TOKEN: ${{ github.token }}
run: |
runuser -u builder -- env GH_TOKEN="$GH_TOKEN" GITHUB_REPOSITORY="$GITHUB_REPOSITORY" \
python scripts/repo_safety.py snapshot "$GITHUB_WORKSPACE/published-assets.json"
- name: Add the kernels to the published repo
if: steps.built.outputs.count != '0'
run: |
set -o pipefail
runuser -u builder -- env GPGKEY="${{ secrets.GPG_KEY_ID }}" GITHUB_REPOSITORY="$GITHUB_REPOSITORY" \
PUBLISHED_ASSETS="$GITHUB_WORKSPACE/published-assets.json" OUTDIR="$GITHUB_WORKSPACE/out" \
bash build-kernel.sh assemble 2>&1 | tee -a publish.log
- name: Publish release safely
if: steps.built.outputs.count != '0'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -o pipefail
runuser -u builder -- env GH_TOKEN="$GH_TOKEN" GITHUB_REPOSITORY="$GITHUB_REPOSITORY" \
python scripts/repo_safety.py publish "$GITHUB_WORKSPACE/out" 2>&1 | tee -a publish.log
- name: Set up the SourceForge key
if: steps.built.outputs.count != '0'
env:
SF_KEY: ${{ secrets.SF_SSH_PRIVATE_KEY }}
run: |
install -d -m 700 /tmp/sf
printf '%s\n' "$SF_KEY" > /tmp/sf/key
chmod 600 /tmp/sf/key
printf '%s\n' 'frs.sourceforge.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQD35Ujalhh+JJkPvMckDlhu4dS7WH6NsOJ15iGCJLC' > /tmp/sf/known_hosts
chmod 600 /tmp/sf/known_hosts
- name: Mirror the repo to SourceForge
if: steps.built.outputs.count != '0'
continue-on-error: true
run: bash scripts/mirror-repo.sh out
- name: Commit the recipes
# The workflow token's push starts no other workflow, so kernels.yml does not build these again.
env:
BRANCH: ${{ github.event.repository.default_branch }}
GH_TOKEN: ${{ github.token }}
run: |
set -o pipefail
runuser -u builder -- env OUT="$GITHUB_WORKSPACE/prepared" BRANCH="$BRANCH" GH_TOKEN="$GH_TOKEN" \
bash scripts/kernel-update.sh commit 2>&1 | tee -a publish.log
- name: Keep the failure for the issue
if: failure()
run: |
mkdir -p failure
if [ -f prepared/failure.md ]; then
cp prepared/failure.md failure/failure.md
else
{ echo "stage: publish"; echo; echo '```'; tail -n 60 publish.log 2>/dev/null; echo '```'; } > failure/failure.md
fi
- uses: actions/upload-artifact@v4
if: failure()
with:
name: failure-publish
path: failure/failure.md
report:
needs: [prepare, build, publish]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
issues: write
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: actions/download-artifact@v4
continue-on-error: true
with:
pattern: failure-*
path: failures
- name: Open or close the issue for this version
env:
GH_TOKEN: ${{ github.token }}
NEEDS: ${{ toJSON(needs) }}
ARCHPKG: ${{ inputs.archpkg }}
MODE: ${{ inputs.mode }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
shopt -s nullglob
python3 scripts/kernel-issue.py report --archpkg "$ARCHPKG" --mode "$MODE" --run-url "$RUN_URL" \
--needs "$NEEDS" failures/*/failure.md