ci(release): a dispatch builds the public release image for GHCR from the export (#8207)
release / web (push) Successful in 1m29s
release / go (push) Successful in 1m58s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 4m17s
release / android (push) Successful in 4m49s
release / Build signed APK (push) Successful in 5m39s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped

A new publishing job, ghcr-release, runs only on a workflow_dispatch with
ghcr_release ticked, behind every verifying lane:

- names the release with ci/version.sh (tag v<name>);
- exports `git archive HEAD`, refuses it if it carries .gitea or ci,
  and matches its tree (staged with add -A -f) to the public repo's
  v<name> tag; a dry run tolerates a missing tag as revision=unreleased;
- stages the freshly built APK and sidecar into the export;
- builds with --provenance=false, labelled source=the GitHub repo,
  revision=the public commit, version=<name>;
- unless ghcr_dry_run (the default), logs in with vars.GHCR_USER and
  secrets.GHCR_TOKEN and pushes :<name> once and :latest. A real run
  must be on main.

image-release stands aside on a GHCR dispatch, so a release moves no
private channel. The concurrency group now includes the event, so a
dispatch and a push on one ref don't cancel each other. The gate test
counts ghcr-release as a publisher and pins its trigger, its export
build, its provenance flag and its source label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 19:41:08 -05:00
co-authored by Claude Opus 5.5
parent e1f270362d
commit 143bb8561c
2 changed files with 244 additions and 7 deletions
+49 -3
View File
@@ -24,9 +24,10 @@ import (
// require its success by name.
var gateLanes = []string{"go", "integration", "web", "android", "govulncheck"}
// gatePublishers push something other people can pull: image tags, and the
// APK + sidecar attached to a Release.
var gatePublishers = []string{"image-release", "release-assets"}
// gatePublishers push something other people can pull: image tags (the
// private channels, and the public release image on GHCR), and the APK +
// sidecar attached to a Release.
var gatePublishers = []string{"image-release", "release-assets", "ghcr-release"}
// gateOthers are the remaining jobs and why they sit outside the gate:
// android-release only builds a workflow artifact (nothing outside the run can
@@ -118,3 +119,48 @@ func TestReleaseGate_PublishersNeedEveryLaneToSucceed(t *testing.T) {
}
}
}
// The public release image has four properties a later edit could quietly
// lose, each of which still builds and pushes a valid image:
// - it runs only on a dispatch that asks for it, never on a push to dev;
// - a GHCR dispatch moves no private channel;
// - it builds from the `git archive` export, so export-ignored files never
// reach its build context;
// - it carries no provenance attestation, and its source label names the
// public repo rather than this workbench.
func TestGHCRRelease_OnlyOnRequestFromTheExportAndNamingThePublicRepo(t *testing.T) {
jobs := releaseJobs(t)
ghcr := strings.Join(strings.Fields(jobs["ghcr-release"].If), " ")
for _, want := range []string{"github.event_name == 'workflow_dispatch'", "github.event.inputs.ghcr_release == 'true'"} {
if !strings.Contains(ghcr, want) {
t.Errorf("ghcr-release's if lacks %s, so it could run on a push\n if: %s", want, ghcr)
}
}
private := strings.Join(strings.Fields(jobs["image-release"].If), " ")
if !strings.Contains(private, "github.event.inputs.ghcr_release != 'true'") {
t.Errorf("image-release does not stand aside on a GHCR dispatch, so a release would also move a private channel\n if: %s", private)
}
yaml := releaseYAML(t)
i := strings.Index(yaml, "\n ghcr-release:")
if i < 0 {
t.Fatal("no ghcr-release job")
}
job := yaml[i:]
if j := jobBoundary.FindStringIndex(job[1:]); j != nil {
job = job[:j[0]+1]
}
export := stepBody(t, job, "Export the public tree and match it to the public tag")
if !strings.Contains(export, "git archive HEAD") {
t.Errorf("the export step does not use git archive, so export-ignored files could reach the image\n%s", export)
}
build := stepBody(t, job, "Build the release image from the export")
for _, want := range []string{"--provenance=false", `"${EXPORT}"`, "org.opencontainers.image.source=\"${PUBLIC_REPO}\""} {
if !strings.Contains(build, want) {
t.Errorf("the release image build lacks %s\n%s", want, build)
}
}
if !strings.Contains(job, "PUBLIC_REPO: https://github.com/Fabled-Sword/minstrel") {
t.Error("ghcr-release's PUBLIC_REPO is not the public GitHub repo, so the image's source label points elsewhere")
}
}