0098. Release images on GHCR, signed, with the GPL source attached
Source:
docs/decisions/0098-release-images-signing-and-source-offer.md. Generated at build time; edit the source file.
- Status: accepted
- Date: 2026-11-23
- Lane:
ci/release-artifacts
Context
Section titled “Context”ADR 0095 made a release a tag, a changelog and a GitHub Release, but nothing a self-hoster can run: every service was built from source with docker compose up --build, which needs about 16 GB of Docker memory and a Rust release build. The worker image also redistributes the Stockfish 19 binary, which is GPL-3.0-or-later, so publishing it obliges us to offer its corresponding source with every copy.
Two facts shaped the design:
- A Release that release-please publishes with the workflow’s
GITHUB_TOKENstarts norelease: publishedworkflow (GitHub’s rule against recursive runs). A workflow listening only for that event would never run on an automatic release. - Merging the release PR pushes the release commit to
main, soCIruns the full gate on exactly the tagged commit, at the same time asRelease.
Decision
Section titled “Decision”- Registry and images. Three images go to GHCR under the owner’s namespace:
ghcr.io/terkea/rematch-web(apps/web/Dockerfile, targetruntime),ghcr.io/terkea/rematch-worker(backend/Dockerfile, targetworker) andghcr.io/terkea/rematch-ai-sidecar(services/ai-sidecar/Dockerfile, targetruntime). The worker image is named for its role, not for the Compose servicerust-worker. Postgres and Redis are the upstream images, pinned by digest indeploy/compose.yaml. Maia (opt-in, ADR-R2-13) is not published; its image carries torch and is built from source with the overlay. GHCR is free for public images, needs no stored secret (the job’sGITHUB_TOKENwithpackages: write), and links each package to the repository throughorg.opencontainers.image.source. - linux/amd64 only.
backend/Dockerfiledownloadsstockfish-linux-x86-64-universal.tar.gzagainst a pinned checksum, so the worker cannot be built for arm64 without a second pinned asset (stockfish-linux-arm64-universal.tar.gzexists upstream), and a Rust release build under QEMU takes hours on a hosted runner. Arm64 waits for a native arm64 runner and that second pin. - Tags.
imageTagsinscripts/release/release-lib.mjs:X.Y.Z,X.Yandbetabelow 1.0;X.Y.Z,X.Y,Xandlatestfrom 1.0; a prerelease such as0.5.0-rc.1only its own tag. Nolatestexists before 1.0, so nobody pulls a beta by accident. The releasedcompose.yamlpinsX.Y.Z@sha256:…, so it never follows a moved tag. - The workflow.
.github/workflows/release-images.yml, withpermissions: {}at the top and each job asking for its own:- triggers:
workflow_callfromrelease.ymlwhen release-please reportsrelease_created(the automatic path);release: publishedfor a Release a person publishes or re-publishes;workflow_dispatchas a dry run on any ref, which builds, smoke-tests and renders the assets and pushes, signs and attaches nothing; gate(contents: read,checks: read): re-runstest-versions.mjs,test-settings.mjsandtest-release.mjson the tag, checks the tag againstpackage.jsonanddeploy/compose.yaml, then waits for CI on the tag’s SHA;images(contents: read,packages: write,id-token: write,attestations: write): builds into the runner’s Docker, runsscripts/release/smoke.sh, then pushes the same builds (every layer a cache hit, buildx cache in the GHA backend per image) withsbom: trueandprovenance: mode=max, attests them withactions/attest-build-provenanceand signs them with keylesscosign sign;assets(contents: read) andattach(contents: write, publish only): the assets below, uploaded with--clobberso a re-run replaces them. Every action is pinned by commit SHA, each release at least 7 days old when pinned: checkout v7.0.1, setup-node v7.1.0, setup-buildx-action v4.4.1, login-action v4.8.0, build-push-action v7.4.0, attest-build-provenance v4.2.2, cosign-installer v4.1.3, upload-artifact v7.0.2, download-artifact v8.0.2.
- triggers:
- The release gate waits for CI on the tagged commit instead of re-running the full gate. The fast checks run again on the tag (seconds); the slow ones (
e2e,e2e-fakes,rust, the schema checks) already run on that exact commit because merging the release PR pushed it tomain.release.mjs ci-gatepolls the commit’s check runs for every required check inrulesets/main.jsonthatci.ymlreports, takes the newest run of each (a re-run supersedes a failure), and passes only onsuccess;cancelled,skippedandfailurefail it. Re-running the full gate inside the release would double an hour of CI for no new information, and a gate that only reads a status frommain’s branch head could be satisfied by a different commit. To keep a later merge from cancelling the run a release waits for,ci.yml’s concurrency group is the commit SHA for pushes and the ref for pull requests. - Smoke test before push.
scripts/release/smoke.shrunsdeploy/compose.yamlitself against the freshly built images (REMATCH_IMAGE_PREFIXandREMATCH_VERSIONpoint it at local tags) in the projectci-release, with no host ports (scripts/release/smoke.compose.yaml), anddown -von exit. It requires/api/healthto answer{"ok":true,"db":true,"redis":true},worker --versionto printworker X.Y.Z(a flag added to the worker for this; any other argument exits 2), the worker to apply everydb/migrationsfile and keep running, the licence files in each image, and the sidecar to turn healthy afterai-sidecar-role. - Signing and supply chain. Keyless cosign, so there is no signing key to store or leak; the certificate binds each signature to
release-images.ymlin this repository through the job’s OIDC token. GitHub build provenance is pushed to the registry and is checked withgh attestation verify oci://… --repo Terkea/rematch. BuildKit’s SPDX SBOM sits in each image index and a copy is attached to the Release.SHA256SUMSis not signed: it checks a download is intact, and the trust comes from the digests incompose.yaml, whichcosign verifychecks. - GPL source offer. Each Release attaches
stockfish-sf_19-source.tar.gz(thesf_19tag archive) andnn-1a298aa575a0.nnue(the network the binary embeds, fromEvalFileDefaultNamein that tag’ssrc/evaluate.h), both downloaded and checked againstdeploy/stockfish-source.txtat release time; a changed upstream file fails the release rather than attaching something that is not the binary’s source. The source travels with the binary instead of a written offer, because an attached file outlives a URL we do not control. Our own source isrematch-X.Y.Z-source.tar.gz(git archiveof the tag), attached to the same Release as the images built from it. Each image carries/usr/share/doc/rematch/LICENSEandNOTICE; the worker also keeps Stockfish’sCopying.txtandAUTHORSfrom the release archive in/usr/share/doc/stockfish/. - Release assets.
deploy/compose.yamlpulls the images and never builds; release-please bumps its three image lines (x-release-please-version, a fourthextra-filesentry) andtest-versions.mjsfails when they differ from the root version. The attachedcompose.yamlis that file rendered with digests (release.mjs render-compose).env.release.examplelists every setting, the required ones enforced by${VAR:?}. - Release notes. release-please writes the changelog;
attachputs.github/release-notes/header.md(the beta status, how to run it, how to verify it, the source offer) above it between<!-- rematch-header -->markers, so a re-run replaces the header instead of stacking it. release-please has no option for a release-body header, so this is a post-step. - Migrations on upgrade. The worker applies
db/migrations(sqlx) at every start before it takes a job, so pulling a newer worker image and starting it is the migration. Migrations only move forward; the upgrade steps indocs/RELEASING.mdtake apg_dumpfirst, and going back means restoring it. - actionlint 1.7.12, pinned by image digest, lints every workflow in the
tsjob, withtest-release.mjsbeside it. Neither is a new required check, so the ruleset is unchanged.
Alternatives
Section titled “Alternatives”- Docker Hub: a second account and a stored token, with pull limits for anonymous users.
release: publishedonly: never fires for release-please’s own Releases. A personal access token for release-please would fix that at the price of a stored secret with write access, which ADR 0095 rejected.- Re-running the whole CI in the release workflow: duplicates about an hour of e2e and Rust per release and proves nothing the push to
maindid not. - A cosign key pair: a long-lived secret in a public repository; keyless signing ties each signature to the workflow instead.
- A written offer for the Stockfish source (GPL-3.0 section 6(b)): it obliges us to answer requests for three years; attaching the source (section 6(a) and (d)) does not.
- Multi-arch now: hours of QEMU per release, and an unverified arm64 Stockfish asset; see decision 2.
Consequences
Section titled “Consequences”- A release takes CI’s duration plus about 40 minutes (the Rust release build with a cold cache), and the
Releaseconcurrency group holds laterReleaseruns until it ends. - After the first release, each GHCR package must be made public once on its settings page.
- A cancelled or failed CI run on the release commit stops the images until it is re-run;
docs/RELEASING.mdlists the cases and the commands. - Bumping Stockfish means a new
backend/Dockerfilepin and new lines indeploy/stockfish-source.txt;test-release.mjschecks the tag in the Dockerfile URL matches the source manifest. - The release workflows now include
release-images.ymlwith write permissions (packages,contentsforattach); ADR 0095’s “the only workflow that writes” now reads “the release workflows”.