Repository navigation
803 lines (730 loc) · 34.9 KB
/
Copy pathdocker-engine.yml
File metadata and controls
803 lines (730 loc) · 34.9 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
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
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
name: docker-engine
# Builds and publishes two GHCR images from the engine crate:
# - ps5upload-engine (engine/Dockerfile) — minimal, no UI
# - ps5upload-engine-webui (engine/Dockerfile.webui) — engine + the full
# React app served over HTTP, for browser/NAS/headless use (no Tauri
# client needed). Its build context is the REPO ROOT, not engine/, since
# it needs to `npm ci && npm run build:vite` in client/ before the Rust
# build embeds the output.
#
# Tag pushes (v*) publish multi-arch (amd64 + arm64) manifests for both
# images, in lockstep — one release cuts both. The build-only smoke-check of
# both Dockerfiles (verify, verify-webui; no push) runs on every push to main,
# nightly, on a dispatch without a tag, and on a PR only when it changes the
# Dockerfiles, their .dockerignore, the smoke script, this workflow or the
# engine's Cargo manifests. Main's push run catches the rest the next commit.
#
# Image tags follow the release policy: every release is cut as a PRE-RELEASE
# and promoted to a full release by hand on GitHub once it has run on a
# console. A tag push therefore publishes ONLY `:<version>`; `:latest` and
# `:<major.minor>` move when the release is promoted (the `release:
# released` event, which fires when a pre-release becomes a release, not when
# a pre-release is published), so `docker pull ...:latest` never gets a build
# nobody has tested — the same contract as the updater's stable channel.
#
# Both images embed the two PS5 ELF images (ps5upload.elf and the DPI
# install daemon) so a browser driving a self-hosted engine can bring the
# DPI daemon up and put the helper back afterwards — the fallback that
# installs a game PATCH. The desktop client does this from its own embeds;
# a browser has no socket and no bytes, so without them the web UI could
# install base games and nothing else (the web UI half of #152). That is why the tag
# builds now start with a `build-payload` job: the main payload is not
# committed (see .gitignore) and needs the PS5 payload SDK.
#
# Manual re-run (e.g. after an Actions outage wedges a tag-push run):
# gh workflow run docker-engine.yml -f tag=v3.3.16
# Manual smoke-check only (no tag: builds and tests both images, publishes nothing):
# gh workflow run docker-engine.yml
#
# A run publishes only on a tag push or a dispatch with a tag: `resolve` runs for those (and
# for `release`) only, and every publishing job needs it.
on:
push:
# A push to main runs the smoke-check only (resolve, and with it every
# publishing job, is off for a branch push).
branches: [main]
tags: ['v*']
pull_request:
paths:
- 'engine/Dockerfile*'
- 'engine/.dockerignore'
- '.dockerignore'
- 'engine/Cargo.lock'
- 'engine/Cargo.toml'
- 'scripts/docker-smoke.sh'
- '.github/workflows/docker-engine.yml'
schedule:
# Nightly smoke-check of both images.
- cron: "23 5 * * *"
workflow_dispatch:
inputs:
tag:
description: "Release tag to publish (e.g. v3.3.16). Must already exist. Empty: only build and smoke-test both images."
required: false
default: ""
# release-tag.yml sets this when it publishes a release as the latest at once: that release
# is created with GITHUB_TOKEN, which fires no `release` event, so `promote` runs here,
# after this run's images are pushed.
promote:
description: "Also move :latest and :<major.minor> to this version once its images are pushed"
type: boolean
default: false
# A pre-release promoted to a release: retag its images as :latest and
# :<major.minor> (the `promote` job). Nothing is rebuilt.
release:
types: [released]
# Least privilege at the top: read-only by default. Only the jobs that actually
# push to GHCR (build*, merge*, promote) opt into packages:write below — the PR
# `verify`/`verify-webui` jobs inherit read-only and never get a write-capable
# token.
permissions:
contents: read
# The promotion run gets its own group: it shares the tag's ref, and sharing
# the build run's group would cancel a still-running image build the moment
# the release is promoted.
concurrency:
group: docker-engine-${{ github.event_name == 'release' && 'promote-' || '' }}${{ github.event.inputs.tag || github.ref }}
cancel-in-progress: true
jobs:
# ── Smoke-check: build amd64, no push ──────────────────────────────────────
verify:
if: >-
github.event_name == 'pull_request' || github.event_name == 'schedule' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.tag == '')
runs-on: ubuntu-24.04
# A full engine (and, for the web UI, client) build: ~7-10 min on a good
# runner, so 10 cancelled ordinary runs (PR #338).
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
submodules: true
- name: Stage the committed DPI daemon for the embed
# ps5upload.elf is not in the repo (it needs the payload SDK), so a
# PR build can only cover the DPI half. That is the half the web
# UI's patch install depends on, and staging it here means a broken
# embed fails the PR rather than the release.
run: |
set -euo pipefail
mkdir -p engine/crates/ps5upload-engine/payload
cp -v payload/installer/ps5upload-installer.elf engine/crates/ps5upload-engine/payload/
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
with:
context: .
file: engine/Dockerfile
platforms: linux/amd64
push: false
# Load it so the smoke test below can run it.
load: true
tags: ps5upload-engine:smoke
cache-from: type=gha
# Written by a push to main only; a PR reads main's layers (RELEASING.md "CI caches").
cache-to: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && 'type=gha,mode=min' || '' }}
# Building proved nothing about whether the image works: 5.40.0 built
# fine and refused every request, had no /tmp for uploads and no
# writable home. Run it and check those.
- name: Smoke-test the image
run: scripts/docker-smoke.sh ps5upload-engine:smoke
# ── Smoke-check of the webui image: same idea, root context + Dockerfile.webui ─
verify-webui:
if: >-
github.event_name == 'pull_request' || github.event_name == 'schedule' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.tag == '')
runs-on: ubuntu-24.04
# A full engine (and, for the web UI, client) build: ~7-10 min on a good
# runner, so 10 cancelled ordinary runs (PR #338).
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
submodules: true
- name: Stage the committed DPI daemon for the embed
# ps5upload.elf is not in the repo (it needs the payload SDK), so a
# PR build can only cover the DPI half. That is the half the web
# UI's patch install depends on, and staging it here means a broken
# embed fails the PR rather than the release.
run: |
set -euo pipefail
mkdir -p engine/crates/ps5upload-engine/payload
cp -v payload/installer/ps5upload-installer.elf engine/crates/ps5upload-engine/payload/
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
# Built exactly as the published image is (no build-args: root prefix).
# The engine reads its URL prefix at run time from PS5UPLOAD_BASE_URL, so
# its routes under a prefix are smoke-tested below on this same image,
# without a second build (which used to be a full engine rebuild). The web
# page takes its prefix at build time (REVERSE_PROXY.md).
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
with:
context: .
file: engine/Dockerfile.webui
platforms: linux/amd64
push: false
load: true
tags: ps5upload-engine-webui:smoke
cache-from: type=gha,scope=webui
cache-to: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && 'type=gha,mode=min,scope=webui' || '' }}
- name: Smoke-test the image
run: scripts/docker-smoke.sh ps5upload-engine-webui:smoke --webui
- name: Smoke-test the same image under a URL prefix
env:
SMOKE_BASE_PATH: /ps5
run: scripts/docker-smoke.sh ps5upload-engine-webui:smoke --webui
# ── Resolve + validate the tag ONCE, hand the trusted values to build/merge ─
# Centralizing this means the tag is regex-validated before it ever reaches a
# checkout `ref:` (no ref injection from a hand-typed workflow_dispatch input),
# and the lowercased image names are computed once via the safe env pattern
# instead of interpolating ${{ github.repository_owner }} into shell.
resolve:
# A tag push, a dispatch with a tag, or a promotion: never a branch push, the schedule, or
# a smoke-check dispatch (the jobs that publish all need this one, so they are off too).
if: >-
github.event_name == 'release' ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '')
runs-on: ubuntu-24.04
timeout-minutes: 5
outputs:
tag: ${{ steps.t.outputs.tag }}
version: ${{ steps.t.outputs.version }}
major_minor: ${{ steps.t.outputs.major_minor }}
image: ${{ steps.t.outputs.image }}
image_webui: ${{ steps.t.outputs.image_webui }}
steps:
- name: Validate tag + derive image names
id: t
env:
INPUT_TAG: ${{ github.event.inputs.tag || github.ref_name }}
OWNER: ${{ github.repository_owner }}
run: |
raw_tag="$INPUT_TAG"
if ! printf '%s' "$raw_tag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+([-+._A-Za-z0-9]*)?$'; then
echo "::error::Refusing to proceed: '$raw_tag' is not a valid version tag"
exit 1
fi
version="${raw_tag#v}"
owner_lc="$(printf '%s' "$OWNER" | tr '[:upper:]' '[:lower:]')"
{
echo "tag=$raw_tag"
echo "version=$version"
echo "major_minor=${version%.*}"
echo "image=ghcr.io/${owner_lc}/ps5upload-engine"
echo "image_webui=ghcr.io/${owner_lc}/ps5upload-engine-webui"
} >> "$GITHUB_OUTPUT"
# ── Build the two PS5 ELF images the engine embeds ─────────────────────────
# Mirrors publish.yml's job of the same name. Duplicated rather than shared
# because the two workflows run independently on a tag push and neither can
# wait on the other's artifacts. The DPI daemon is committed, but the main
# payload is not (see .gitignore), and the engine needs BOTH: it streams the
# daemon to the loader on :9021 and then puts ps5upload back afterwards.
build-payload:
needs: resolve
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
# 45: the converter's Docker toolchain is built here when engine-ci's cache of it is gone.
timeout-minutes: 45
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
submodules: true
ref: ${{ needs.resolve.outputs.tag }}
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version: 22
# Always the newest 22.x (security releases; the runner image can lag).
check-latest: true
cache: npm
cache-dependency-path: client/package-lock.json
# make payload embeds the console web page (payload/Makefile: build/webui_page.c runs
# `npm run build:console` in client/), so the client's dependencies must be installed.
- name: Install client deps (console web page)
working-directory: client
run: npm ci --no-audit --no-fund
- name: Install payload toolchain
timeout-minutes: 20
run: |
set -euo pipefail
# llvm-22 is not in Ubuntu 24.04's default repos.
sudo bash scripts/install-llvm-apt.sh 22
# Bounded and retried: a stalled apt mirror must not hold the job (scripts/ci-apt.sh).
# ci-apt-latest.sh: a tag's image build runs main's copy of it (a pull request its own).
bash scripts/ci-apt-latest.sh clang-22 llvm-22-dev lld-22 unzip python3
- name: Install pinned PS5 Payload SDK
run: sudo env PS5_SDK_INSTALL_DIR=/opt/ps5-payload-sdk bash scripts/install-ps5-sdk.sh
# The converter the helper carries (payload/convert), built in Docker, as publish.yml's
# build-payload builds it: without it the helper in these images could not convert on the
# console. Its toolchain image comes from engine-ci's cache when main has saved one (same
# key); else build.sh builds it. Not saved from here: a tag's cache is not one later runs read.
- name: Restore the converter's toolchain image
id: convert-image
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ${{ runner.temp }}/convert-toolchain.tar
key: ${{ runner.os }}-${{ runner.arch }}-convert-toolchain-${{ hashFiles('payload/convert/Dockerfile', 'payload/convert/prepare-rust-std.py', 'scripts/ps5-sdk.env') }}
- name: Load the converter's toolchain image
if: steps.convert-image.outputs.cache-hit == 'true'
run: docker load -i "$RUNNER_TEMP/convert-toolchain.tar"
- name: Build the converter (make console-convert)
timeout-minutes: 20
env:
DOCKER_BUILDKIT: 1
run: make console-convert
- name: Build payload ELFs
env:
PS5_PAYLOAD_SDK: /opt/ps5-payload-sdk
# SDK v0.42's prospero-llvm-config candidate search maxes at 21,
# so point it at the CI-installed LLVM 22 explicitly.
LLVM_CONFIG: /usr/bin/llvm-config-22
# Never a helper without the converter: payload/Makefile fails the build when
# payload/convert/ps5upload-convert.elf is missing.
CONVERT_REQUIRED: 1
run: make payload
- name: Sanity-check ELF shape
run: |
file payload/ps5upload.elf payload/installer/ps5upload-installer.elf
test -s payload/ps5upload.elf
test -s payload/installer/ps5upload-installer.elf
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: ps5upload-payload-elves
path: |
payload/ps5upload.elf
payload/installer/ps5upload-installer.elf
if-no-files-found: error
retention-days: 1
# ── Per-arch native build, push by digest (no tag yet) ─────────────────────
build:
needs: [resolve, build-payload]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
timeout-minutes: 30
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-24.04, platform: linux/amd64 }
- { os: ubuntu-24.04-arm, platform: linux/arm64 }
env:
IMAGE: ${{ needs.resolve.outputs.image }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
submodules: true
ref: ${{ needs.resolve.outputs.tag }}
- name: Prepare environment
env:
PLATFORM: ${{ matrix.platform }}
run: echo "PLATFORM_PAIR=$(printf '%s' "$PLATFORM" | tr '/' '-')" >> "$GITHUB_ENV"
# Both arm64 legs of v7.1.19 failed right here ("Artifact download failed
# after 5 retries", a 25 s blob-store flake), and the release's images
# waited hours for a hand re-run. One more attempt after a pause.
- name: Stage the PS5 ELF images for the engine embed
id: elves
continue-on-error: true
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: ps5upload-payload-elves
path: /tmp/payload-elves
- name: Wait before retrying the artifact download
if: steps.elves.outcome == 'failure'
run: sleep 30
- name: Stage the PS5 ELF images for the engine embed (retry)
if: steps.elves.outcome == 'failure'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: ps5upload-payload-elves
path: /tmp/payload-elves
- name: Move them into the engine's embed directory
# `build.rs` looks here first — the same convention `webui/` uses for
# the React bundle, so the images ride along in the existing
# `COPY engine/` layer and no Dockerfile needs a second context path.
run: |
set -euo pipefail
mkdir -p engine/crates/ps5upload-engine/payload
cp -v /tmp/payload-elves/ps5upload.elf \
/tmp/payload-elves/installer/ps5upload-installer.elf \
engine/crates/ps5upload-engine/payload/
ls -la engine/crates/ps5upload-engine/payload/
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
id: meta
with:
images: ${{ env.IMAGE }}
# Same build, loaded locally and run before anything is pushed: a
# release tag can't be moved, so a broken image would need a new release.
- name: Build for the smoke test
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
with:
context: .
file: engine/Dockerfile
platforms: ${{ matrix.platform }}
load: true
tags: ps5upload-smoke:local
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
- name: Smoke-test the image
run: scripts/docker-smoke.sh ps5upload-smoke:local
- name: Build and push by digest
id: push
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
with:
context: .
file: engine/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max
- name: Export digest
env:
DIGEST: ${{ steps.push.outputs.digest }}
run: |
mkdir -p /tmp/digests
touch "/tmp/digests/${DIGEST#sha256:}"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# ── Per-arch native build of the webui image, push by digest ───────────────
# Mirrors `build` above; only the context/file/image/artifact-name/cache-
# scope differ. Kept as a separate job (not a matrix dimension on `build`)
# so a webui-only failure doesn't need `fail-fast: false` gymnastics to
# keep the plain engine image publishing on time.
build-webui:
needs: [resolve, build-payload]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
timeout-minutes: 30
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-24.04, platform: linux/amd64 }
- { os: ubuntu-24.04-arm, platform: linux/arm64 }
env:
IMAGE: ${{ needs.resolve.outputs.image_webui }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
submodules: true
ref: ${{ needs.resolve.outputs.tag }}
- name: Prepare environment
env:
PLATFORM: ${{ matrix.platform }}
run: echo "PLATFORM_PAIR=$(printf '%s' "$PLATFORM" | tr '/' '-')" >> "$GITHUB_ENV"
# Both arm64 legs of v7.1.19 failed right here ("Artifact download failed
# after 5 retries", a 25 s blob-store flake), and the release's images
# waited hours for a hand re-run. One more attempt after a pause.
- name: Stage the PS5 ELF images for the engine embed
id: elves
continue-on-error: true
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: ps5upload-payload-elves
path: /tmp/payload-elves
- name: Wait before retrying the artifact download
if: steps.elves.outcome == 'failure'
run: sleep 30
- name: Stage the PS5 ELF images for the engine embed (retry)
if: steps.elves.outcome == 'failure'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: ps5upload-payload-elves
path: /tmp/payload-elves
- name: Move them into the engine's embed directory
# `build.rs` looks here first — the same convention `webui/` uses for
# the React bundle, so the images ride along in the existing
# `COPY engine/` layer and no Dockerfile needs a second context path.
run: |
set -euo pipefail
mkdir -p engine/crates/ps5upload-engine/payload
cp -v /tmp/payload-elves/ps5upload.elf \
/tmp/payload-elves/installer/ps5upload-installer.elf \
engine/crates/ps5upload-engine/payload/
ls -la engine/crates/ps5upload-engine/payload/
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
id: meta
with:
images: ${{ env.IMAGE }}
# Same build, loaded locally and run before anything is pushed: a
# release tag can't be moved, so a broken image would need a new release.
# No build-args, so this IS the image pushed below (the push step is a
# cache hit): it used to be built with PS5UPLOAD_BASE_URL=/ps5/, which
# tested a different image and rebuilt the whole engine for the push.
# The prefix is applied at run time, so the prefixed deployment is
# covered by running the same image with that variable set.
- name: Build for the smoke test
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
with:
context: .
file: engine/Dockerfile.webui
platforms: ${{ matrix.platform }}
load: true
tags: ps5upload-smoke:local
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
- name: Smoke-test the image
run: scripts/docker-smoke.sh ps5upload-smoke:local --webui
- name: Smoke-test the same image under a URL prefix
env:
SMOKE_BASE_PATH: /ps5
run: scripts/docker-smoke.sh ps5upload-smoke:local --webui
- name: Build and push by digest
id: push
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7
with:
context: .
file: engine/Dockerfile.webui
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }}
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max
- name: Export digest
env:
DIGEST: ${{ steps.push.outputs.digest }}
run: |
mkdir -p /tmp/digests
touch "/tmp/digests/${DIGEST#sha256:}"
# Distinct "webui-digests-" prefix (not just a "webui-" infix) so the
# plain engine `merge` job's `pattern: digests-*` can't glob-match
# these artifacts and fold a webui digest into the minimal image's
# manifest.
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: webui-digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# ── Merge per-arch digests into a multi-arch manifest ──────────────────────
merge:
needs: [resolve, build]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
packages: write
env:
IMAGE: ${{ needs.resolve.outputs.image }}
VERSION: ${{ needs.resolve.outputs.version }}
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
id: meta
with:
images: ${{ env.IMAGE }}
# Only the version: :latest and :<major.minor> are moved by `promote`
# when the pre-release is promoted (see the header).
tags: |
type=raw,value=${{ env.VERSION }}
- name: Create and push multi-arch manifest
working-directory: /tmp/digests
env:
META_JSON: ${{ steps.meta.outputs.json }}
run: |
# Word-splitting here is intentional: the jq output expands to
# `-t tagA -t tagB ...` and the printf to space-separated
# `image@sha256:<digest>` operands, each a distinct argv entry.
# shellcheck disable=SC2046
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$META_JSON") \
$(printf "${IMAGE}@sha256:%s " *)
- name: Inspect manifest
run: docker buildx imagetools inspect "${IMAGE}:${VERSION}"
# ── Merge the webui image's per-arch digests ────────────────────────────────
merge-webui:
needs: [resolve, build-webui]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
packages: write
env:
IMAGE: ${{ needs.resolve.outputs.image_webui }}
VERSION: ${{ needs.resolve.outputs.version }}
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
path: /tmp/digests
pattern: webui-digests-*
merge-multiple: true
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
id: meta
with:
images: ${{ env.IMAGE }}
# Only the version: :latest and :<major.minor> are moved by `promote`
# when the pre-release is promoted (see the header).
tags: |
type=raw,value=${{ env.VERSION }}
- name: Create and push multi-arch manifest
working-directory: /tmp/digests
env:
META_JSON: ${{ steps.meta.outputs.json }}
run: |
# shellcheck disable=SC2046
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$META_JSON") \
$(printf "${IMAGE}@sha256:%s " *)
- name: Inspect manifest
run: docker buildx imagetools inspect "${IMAGE}:${VERSION}"
# ── Promotion: a pre-release became a release → move :latest + :<major.minor> ─
# Fires on `release: released` (promoting a pre-release by hand, or an
# edit that clears the pre-release flag), never on the pre-release that
# create-release publishes; and on a dispatch with promote=true, after that
# run's own manifests are pushed. Nothing is rebuilt: the multi-arch manifest the
# tag run pushed as :<version> is re-tagged, for both images. Waits while the
# tag run is still building, and fails loudly if a manifest never appears.
promote:
needs: [resolve, merge, merge-webui]
# always(): on a `release` event merge and merge-webui are skipped (they build tag runs only).
if: >-
always() && needs.resolve.result == 'success' &&
(github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.promote == 'true' &&
needs.merge.result == 'success' && needs.merge-webui.result == 'success'))
runs-on: ubuntu-24.04
# The wait below (45 min at most) plus the retag.
timeout-minutes: 60
permissions:
contents: read
packages: write
env:
TAG: ${{ needs.resolve.outputs.tag }}
VERSION: ${{ needs.resolve.outputs.version }}
MAJOR_MINOR: ${{ needs.resolve.outputs.major_minor }}
IMAGES: ${{ needs.resolve.outputs.image }} ${{ needs.resolve.outputs.image_webui }}
steps:
# `:latest` follows the release page, not this workflow's inputs. On a `promote=true`
# dispatch the images are ready before publish.yml has made the release (publish ends
# 5 to 25 minutes after this run's builds), and if publish fails there is no release at
# all: `:latest` then stays where it is. On a `release` event this passes at once.
- name: Wait until the release is published and not a pre-release
id: release
timeout-minutes: 50
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
state=""
for _ in $(seq 1 90); do
state="$(gh release view "$TAG" --json isPrerelease,isDraft \
--jq '"prerelease=\(.isPrerelease) draft=\(.isDraft)"' 2>/dev/null || true)"
if [ "$state" = "prerelease=false draft=false" ]; then
break
fi
echo "release $TAG: ${state:-not there yet}; waiting"
sleep 30
done
if [ "$state" != "prerelease=false draft=false" ]; then
echo "::error::$TAG is not a published full release after 45 minutes (${state:-no release}); :latest was not moved. Once the release is out and promoted, re-run this job."
exit 1
fi
echo "$TAG is a published release."
# Never backwards: promoting an older version (a fix for an old line, or a late
# re-run) must not take :latest off a newer release, nor :<major.minor> off a newer
# patch of the same line. Equal is fine (this release is the latest).
lower() {
[ "$1" != "$2" ] && [ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | head -n 1)" = "$1" ]
}
latest_tag="$(gh api "repos/$GH_REPO/releases/latest" --jq .tag_name)"
latest="${latest_tag#v}"
move_latest=true
if lower "$VERSION" "$latest"; then
move_latest=false
echo "::notice::$VERSION is older than the latest release ($latest): :latest stays where it is"
fi
line_top="$(gh api --paginate "repos/$GH_REPO/releases?per_page=100" \
--jq '.[] | select((.draft | not) and (.prerelease | not)) | .tag_name' \
| sed 's/^v//' | awk -v p="$MAJOR_MINOR." 'index($0, p) == 1' | sort -V | tail -n 1)"
move_line=true
if [ -n "$line_top" ] && lower "$VERSION" "$line_top"; then
move_line=false
echo "::notice::$VERSION is older than $line_top: :$MAJOR_MINOR stays where it is"
fi
{
echo "move_latest=$move_latest"
echo "move_line=$move_line"
} >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Wait until both images are published
timeout-minutes: 12
run: |
set -euo pipefail
for image in $IMAGES; do
for attempt in $(seq 1 20); do
if docker buildx imagetools inspect "${image}:${VERSION}" >/dev/null 2>&1; then
break
fi
if [ "$attempt" -eq 20 ]; then
echo "::error::${image}:${VERSION} was not published after 10 minutes: did the tag's docker-engine run fail? :latest was not moved. Once both images are out, re-run this job."
exit 1
fi
echo "${image}:${VERSION}: not there yet; waiting"
sleep 30
done
done
- name: Retag both images as latest and major.minor
env:
MOVE_LATEST: ${{ steps.release.outputs.move_latest }}
MOVE_LINE: ${{ steps.release.outputs.move_line }}
run: |
set -euo pipefail
for image in $IMAGES; do
tags=()
if [ "$MOVE_LATEST" = true ]; then tags+=(-t "${image}:latest"); fi
if [ "$MOVE_LINE" = true ]; then tags+=(-t "${image}:${MAJOR_MINOR}"); fi
if [ "${#tags[@]}" -eq 0 ]; then
echo "${image}: nothing to move for ${VERSION}"
continue
fi
docker buildx imagetools create "${tags[@]}" "${image}:${VERSION}"
docker buildx imagetools inspect "${image}:${tags[1]##*:}"
done