-
Notifications
You must be signed in to change notification settings - Fork 2
554 lines (482 loc) · 18.9 KB
/
build.yml
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
---
name: "Build Gluon images"
# yamllint disable-line rule:truthy
on:
pull_request:
push:
workflow_dispatch:
inputs:
repository:
description: 'Repository path (e.g. freifunk-gluon/gluon)'
required: true
reference:
description: 'Reference (commit / tag)'
required: true
targets:
description: 'Targets to build (space separated)'
required: false
jobs:
build-meta:
outputs:
container-version: >-
${{ steps.build-metadata.outputs.container-version }}
release-version: >-
${{ steps.build-metadata.outputs.release-version }}
site-version: >-
${{ steps.build-metadata.outputs.site-version }}
autoupdater-enabled: >-
${{ steps.build-metadata.outputs.autoupdater-enabled }}
autoupdater-branch: >-
${{ steps.build-metadata.outputs.autoupdater-branch }}
broken: >-
${{ steps.build-metadata.outputs.broken }}
gluon-repository: >-
${{ steps.build-metadata.outputs.gluon-repository }}
gluon-commit: >-
${{ steps.build-metadata.outputs.gluon-commit }}
manifest-stable: >-
${{ steps.build-metadata.outputs.manifest-stable }}
manifest-beta: >-
${{ steps.build-metadata.outputs.manifest-beta }}
manifest-testing: >-
${{ steps.build-metadata.outputs.manifest-testing }}
sign-manifest: >-
${{ steps.build-metadata.outputs.sign-manifest }}
create-release: >-
${{ steps.build-metadata.outputs.create-release }}
latest-release: >-
${{ steps.build-metadata.outputs.latest-release }}
deploy: >-
${{ steps.build-metadata.outputs.deploy }}
link-release: >-
${{ steps.build-metadata.outputs.link-release }}
target-whitelist: >-
${{ steps.build-metadata.outputs.target-whitelist }}
env:
WORKFLOW_DISPATCH_REPOSITORY: ${{ github.event.inputs.repository }}
WORKFLOW_DISPATCH_REFERENCE: ${{ github.event.inputs.reference }}
WORKFLOW_DISPATCH_TARGETS: ${{ github.event.inputs.targets }}
runs-on: ubuntu-22.04
name: Determine build-meta
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Set Timezone
run: sudo timedatectl set-timezone Europe/Berlin
- name: Show current Timezone settings
run: timedatectl status
- name: Fetch upstream tags
# yamllint disable rule:line-length
if: ${{ github.repository != 'freifunk-darmstadt/site-ffda' }}
run: |
git remote add upstream https://github.com/freifunk-darmstadt/site-ffda.git
git fetch upstream --tags
# yamllint enable rule:line-length
- name: Get build-metadata
id: build-metadata
run: bash .github/build-meta.sh
- name: Create Artifact of build-meta
uses: actions/upload-artifact@v4
with:
name: build-meta
path: ${{ steps.build-metadata.outputs.build-meta-output }}
targets:
needs: build-meta
outputs:
targets: ${{ steps.get-targets.outputs.targets }}
runs-on: ubuntu-22.04
name: Get Gluon targets
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: ${{ needs.build-meta.outputs.gluon-repository }}
ref: ${{ needs.build-meta.outputs.gluon-commit }}
path: 'gluon-gha-data/gluon'
- name: Get Targets
uses: freifunk-gluon/action-target-list@v1
id: get-targets
with:
gluon-path: "gluon-gha-data/gluon"
broken: ${{ needs.build-meta.outputs.broken }}
allowlist: ${{ needs.build-meta.outputs.target-whitelist }}
host-tools:
needs: build-meta
runs-on: ubuntu-22.04
name: Build host-tools
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: ${{ needs.build-meta.outputs.gluon-repository }}
ref: ${{ needs.build-meta.outputs.gluon-commit }}
path: 'gluon-gha-data/gluon'
- name: Determine Cache-Key
id: cache-key
run: >
echo "cache-key=$(bash .github/cache-key.sh
$GITHUB_WORKSPACE/gluon-gha-data/gluon)" >> "$GITHUB_OUTPUT"
- name: Restore Cache
id: restore-cache-tools
uses: actions/cache/restore@v4
with:
path: gluon-gha-data/gluon/openwrt
key: openwrt-${{ steps.cache-key.outputs.cache-key }}
- name: Update Gluon
uses: freifunk-gluon/action-build@v1
if: steps.restore-cache-tools.outputs.cache-hit != 'true'
id: update-gluon
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
make-target: update
site-path: "."
- name: Build host-tools
uses: freifunk-gluon/action-build@v1
if: steps.restore-cache-tools.outputs.cache-hit != 'true'
id: build-host-tools
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
make-target: openwrt/staging_dir/hostpkg/bin/lua
site-path: "."
- name: Save Cache
id: save-cache-tools
if: >
github.ref_type != 'tag' &&
steps.restore-cache-tools.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: gluon-gha-data/gluon/openwrt
key: openwrt-${{ steps.cache-key.outputs.cache-key }}
- name: Create Artifact output directory
run: mkdir gluon-gha-data/openwrt
- name: Pack Output
run: >
tar cJf "gluon-gha-data/openwrt/openwrt.tar.xz"
--posix -C "gluon-gha-data/gluon" openwrt
- name: Archive build output
uses: actions/upload-artifact@v4
with:
name: openwrt
path: "gluon-gha-data/openwrt"
compression-level: 0
build:
needs: [targets, build-meta, host-tools]
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.targets.outputs.targets) }}
runs-on: ubuntu-22.04
if: >
needs.targets.outputs.targets != '[]'
permissions:
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: ${{ needs.build-meta.outputs.gluon-repository }}
ref: ${{ needs.build-meta.outputs.gluon-commit }}
path: 'gluon-gha-data/gluon'
fetch-depth: 0
fetch-tags: true
- name: Fetch upstream tags
# yamllint disable rule:line-length
if: ${{ needs.build-meta.outputs.gluon-repository != 'freifunk-gluon/gluon' }}
run: |
git -C gluon-gha-data/gluon remote add upstream https://github.com/freifunk-gluon/gluon.git
git -C gluon-gha-data/gluon fetch upstream --tags
# yamllint enable rule:line-length
- name: Print CPU info
run: cat /proc/cpuinfo
- name: Print meminfo
run: cat /proc/meminfo
- name: Download prepared OpenWrt
uses: actions/download-artifact@v4
with:
name: openwrt
path: "gluon-gha-data/openwrt"
- name: Restore OpenWrt
run: >
tar xf gluon-gha-data/openwrt/openwrt.tar.xz -C gluon-gha-data/gluon
- name: Gluon Update
uses: freifunk-gluon/action-build@v1
id: update-gluon
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
hardware-target: ath79-generic
make-target: update
- name: Build
# yamllint disable-line rule:line-length
uses: freifunk-gluon/action-build@3a48a4d0db08ff393e08ec3074f1b218ee5ac54b
id: build-gluon
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
hardware-target: ${{ matrix.target }}
broken: ${{ needs.build-meta.outputs.broken }}
deprecated: "0"
autoupdater-enabled: |
${{ needs.build-meta.outputs.autoupdater-enabled }}
autoupdater-branch: |
${{ needs.build-meta.outputs.autoupdater-branch }}
release: ${{ needs.build-meta.outputs.release-version }}
site-version: ${{ needs.build-meta.outputs.site-version }}
- name: Pack and Upload build output
uses: ./.github/actions/build-artifact
with:
gluon-path: "gluon-gha-data/gluon"
hardware-target: ${{ matrix.target }}
- name: Attest Image Build Provenance
if: ${{ needs.build-meta.outputs.create-release != '0' }}
uses: actions/attest-build-provenance@v1
with:
subject-path: |
"gluon-gha-data/gluon/output/images/sysupgrade/*"
"gluon-gha-data/gluon/output/images/other/*"
"gluon-gha-data/gluon/output/images/factory/*"
manifest:
needs: [build, build-meta, targets]
runs-on: ubuntu-22.04
if: >
needs.targets.outputs.targets != '[]' &&
github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: "gluon-gha-data/gluon-output"
- name: Clone Gluon
uses: actions/checkout@v4
with:
repository: ${{ needs.build-meta.outputs.gluon-repository }}
ref: ${{ needs.build-meta.outputs.gluon-commit }}
path: 'gluon-gha-data/gluon'
- name: Download prepared OpenWrt
uses: actions/download-artifact@v4
with:
name: openwrt
path: "gluon-gha-data/openwrt"
- name: Restore OpenWrt
run: |
tar xf gluon-gha-data/openwrt/openwrt.tar.xz -C gluon-gha-data/gluon
- name: Combine Build output
uses: ./.github/actions/build-combine
with:
artifact-dir: "gluon-gha-data/gluon-output"
output-dir: "gluon-gha-data/gluon/output"
targets: ${{ needs.targets.outputs.targets }}
- name: Gluon Update
uses: freifunk-gluon/action-build@v1
id: update-gluon
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
make-target: update
- name: Manifest (Stable)
uses: freifunk-gluon/action-build@v1
if: ${{ needs.build-meta.outputs.manifest-stable != '0' }}
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
make-target: manifest
autoupdater-branch: stable
release: ${{ needs.build-meta.outputs.release-version }}
priority: 1
- name: Manifest (Beta)
uses: freifunk-gluon/action-build@v1
if: ${{ needs.build-meta.outputs.manifest-beta != '0' }}
with:
container-version: >-
${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
make-target: manifest
autoupdater-branch: beta
release: >-
${{ needs.build-meta.outputs.release-version }}
priority: 1
- name: Manifest (Testing)
uses: freifunk-gluon/action-build@v1
if: ${{ needs.build-meta.outputs.manifest-testing != '0' }}
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
make-target: manifest
autoupdater-branch: testing
release: ${{ needs.build-meta.outputs.release-version }}
priority: 1
broken: ${{ needs.build-meta.outputs.broken }}
- name: Sign manifest (Stable)
uses: freifunk-gluon/action-sign@v1
if: >
needs.build-meta.outputs.manifest-stable != '0' &&
needs.build-meta.outputs.sign-manifest != '0'
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
manifest: >-
gluon-gha-data/gluon/output/images/sysupgrade/stable.manifest
signing-key: ${{ secrets.GHA_FFDA_BUILD_ECDSA_KEY_STABLE }}
write-signature: "true"
- name: Sign manifest (Beta)
uses: freifunk-gluon/action-sign@v1
if: >
needs.build-meta.outputs.manifest-beta != '0' &&
needs.build-meta.outputs.sign-manifest != '0'
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
manifest: >-
gluon-gha-data/gluon/output/images/sysupgrade/beta.manifest
signing-key: ${{ secrets.GHA_FFDA_BUILD_ECDSA_KEY_BETA }}
write-signature: "true"
- name: Sign manifest (Testing)
uses: freifunk-gluon/action-sign@v1
if: >
needs.build-meta.outputs.manifest-testing != '0' &&
needs.build-meta.outputs.sign-manifest != '0'
with:
container-version: ${{ needs.build-meta.outputs.container-version }}
gluon-path: "gluon-gha-data/gluon"
manifest: >-
gluon-gha-data/gluon/output/images/sysupgrade/testing.manifest
signing-key: ${{ secrets.GHA_FFDA_BUILD_ECDSA_KEY_TESTING }}
write-signature: "true"
- name: Create Artifact Directory
run: mkdir gluon-gha-data/artifact-out
- name: Structure
run: tree gluon-gha-data/gluon
- name: Pack Manifest
run: >
find ./gluon-gha-data/gluon/output/images/sysupgrade
-maxdepth 1 -name "*.manifest" -exec basename {} \; |
tar cJf gluon-gha-data/artifact-out/manifest.tar.xz
-C gluon-gha-data/gluon/output/images/sysupgrade -T -
- name: Archive output
uses: actions/upload-artifact@v4
with:
name: manifest-signed
path: gluon-gha-data/artifact-out
deploy:
needs: [build, build-meta, targets, manifest]
runs-on: ubuntu-22.04
if: >
needs.targets.outputs.targets != '[]' &&
needs.build-meta.outputs.deploy != '0' &&
github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: "gluon-gha-data/artifact-download"
- name: Create Directory to store Gluon output into
run: mkdir gluon-gha-data/gluon-output
- name: Combine Build output
uses: ./.github/actions/build-combine
with:
artifact-dir: "gluon-gha-data/artifact-download"
output-dir: "gluon-gha-data/gluon-output/output"
targets: ${{ needs.targets.outputs.targets }}
- name: Extract Manifest
run: >
tar xf
gluon-gha-data/artifact-download/manifest-signed/manifest.tar.xz
-C gluon-gha-data/gluon-output/output/images/sysupgrade
- name: Save SSH Key for deployment
run: >
mkdir -p ~/.ssh &&
echo "${{ secrets.GHA_FFDA_BUILD_DEPLOY_SSH_KEY }}" >
~/.ssh/deploy_key && chmod 600 ~/.ssh/deploy_key
- name: Deploy Images
# yamllint disable-line rule:line-length
run: rsync -avzP -e "ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key -oIdentitiesOnly=yes" gluon-gha-data/gluon-output/output/images/{factory,sysupgrade,other} "[email protected]:/srv/firmware/images/${{ needs.build-meta.outputs.release-version }}/"
- name: Deploy Packages
# ToDo: Remove 'ffda' site-code and move to build-meta
# yamllint disable-line rule:line-length
run: rsync -avzP -e "ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key -oIdentitiesOnly=yes" "gluon-gha-data/gluon-output/output/packages/gluon-ffda-${{ needs.build-meta.outputs.release-version }}" "[email protected]:/srv/firmware/modules/"
link-release:
needs: [build, build-meta, targets, manifest, deploy]
runs-on: ubuntu-22.04
if: >
needs.targets.outputs.targets != '[]' &&
needs.build-meta.outputs.deploy != '0' &&
needs.build-meta.outputs.link-release != '0' &&
github.event_name == 'push'
steps:
- name: Save SSH Key for deployment
run: >
mkdir -p ~/.ssh &&
echo "${{ secrets.GHA_FFDA_BUILD_DEPLOY_SSH_KEY }}" >
~/.ssh/deploy_key && chmod 600 ~/.ssh/deploy_key
- name: Link Release
env:
RELEASE_VERSION: ${{ needs.build-meta.outputs.release-version }}
AUTOUPDATER_BRANCH: ${{ needs.build-meta.outputs.autoupdater-branch }}
# yamllint disable rule:line-length
run: >
ssh
-i ~/.ssh/deploy_key
-q
-oUserKnownHostsFile=/dev/null
-oStrictHostKeyChecking=no
-oIdentitiesOnly=yes
"ln -n -f -s /srv/firmware/images/$RELEASE_VERSION /srv/firmware/images/$AUTOUPDATER_BRANCH"
# yamllint enable rule:line-length
create-release:
needs: [build, build-meta, targets, manifest]
runs-on: ubuntu-22.04
if: >
needs.targets.outputs.targets != '[]' &&
needs.build-meta.outputs.create-release != '0' &&
github.event_name == 'push'
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: "gluon-gha-data/artifact-download"
- name: Create Directory to store Gluon output into
run: mkdir gluon-gha-data/gluon-output
- name: Download target Artifacts
uses: ./.github/actions/build-combine
with:
artifact-dir: "gluon-gha-data/artifact-download"
output-dir: "gluon-gha-data/release-artifacts"
targets: ${{ needs.targets.outputs.targets }}
keep-packed: 1
- name: Move manifest archive
run: >-
mv gluon-gha-data/artifact-download/manifest-signed/manifest.tar.xz
gluon-gha-data/release-artifacts/manifest.tar.xz
- name: Move manifest archive
run: >-
mv gluon-gha-data/artifact-download/build-meta/build-meta.txt
gluon-gha-data/release-artifacts/build-meta.txt
- name: Show File sizes
run: du -sh gluon-gha-data/release-artifacts/*
- name: Create Release Notes
run: >-
bash .github/create-release-notes.sh
gluon-gha-data/release-artifacts/build-meta.txt
gluon-gha-data/release-notes.md
- name: Attest Release Artifact Build Provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: |
gluon-gha-data/release-artifacts/*
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: gluon-gha-data/release-notes.md
make_latest: ${{ needs.build-meta.outputs.latest-release == '1' }}
files: |
gluon-gha-data/release-artifacts/*