ci: a merge to main is the public release; every dev push dry-runs it (#8358)
release / web (push) Successful in 1m29s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m44s
release / android (push) Successful in 2m9s
release / Build signed APK (push) Successful in 2m1s
release / Build + push container image (push) Failing after 4s

Every push now builds its image from the git archive export, after the
changelog and the leak gate have run on it, so a dev push is the public
release's dry run. A push to main then also commits and tags the export on
github.com/Fabled-Sword/minstrel as AmateurDungeoneer, publishes
ghcr.io/fabled-sword/minstrel :<name> and :latest, and creates the release
page on GitHub (public changelog) and on this forge (private changelog).

The scripts are Librarian's (ci/changelog.sh, ci/leakgate.sh,
ci/releases.mjs, with their tests), with Minstrel's false positives and a
changelog that ignores the forge-only v* tags from before the public
releases, so the first public release is the fixed note.

The tag build, its APK attach and its verify job, and the manual GHCR
dispatch are gone: phones get the app from the server image, and no
release carries a file. The push trigger has no path filter, because the
README, docs and tests ship in the public release too.

The README's image tags now name what GHCR carries: :latest and :<version>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 20:07:36 -05:00
co-authored by Claude Opus 5.5
parent fde5cbbafd
commit 7ced019c77
11 changed files with 788 additions and 570 deletions
+60 -41
View File
@@ -3,6 +3,7 @@ package server
import (
"os"
"path/filepath"
"regexp"
"slices"
"strings"
"testing"
@@ -24,15 +25,14 @@ import (
// require its success by name.
var gateLanes = []string{"go", "integration", "web", "android", "govulncheck"}
// 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"}
// gatePublishers push something other people can pull: image-release pushes
// the private channels and, on main, the whole public release.
var gatePublishers = []string{"image-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
// pull it), and verify-release reports on a finished release.
var gateOthers = []string{"android-release", "verify-release"}
// pull it).
var gateOthers = []string{"android-release"}
type workflowJob struct {
Needs any `yaml:"needs"`
@@ -120,47 +120,66 @@ 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)
}
// The public release has properties a later edit could quietly lose, each of
// which still builds and pushes a valid release:
// - only a push to main makes it, never a dev push or a dispatch;
// - every image is built from the `git archive` export, so export-ignored
// files never reach a build context, and the export and the public
// changelog pass the leak gate before anything is built or pushed;
// - the public image carries no provenance attestation, and its labels name
// the public repository and commit rather than this workbench;
// - the public commit is the family's public identity, dated in UTC.
func TestPublicRelease_OnlyFromAMainPushBuiltFromTheGatedExport(t *testing.T) {
yaml := releaseYAML(t)
i := strings.Index(yaml, "\n ghcr-release:")
i := strings.Index(yaml, "\n image-release:")
if i < 0 {
t.Fatal("no ghcr-release job")
t.Fatal("no image-release job")
}
job := yaml[i:]
if j := jobBoundary.FindStringIndex(job[1:]); j != nil {
job = job[:j[0]+1]
tags := stepBody(t, job, "Compute image tags")
public := regexp.MustCompile(`if \[ "\$\{GITHUB_EVENT_NAME\}" = "push" \] && \[ "\$\{GITHUB_REF\}" = "refs/heads/main" \]; then\s+echo "PUBLIC=true"\s+else\s+echo "PUBLIC=false"`)
if !public.MatchString(tags) {
t.Errorf("PUBLIC is not true for a push to main alone, so another run could publish the release\n%s", tags)
}
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)
for _, step := range []string{"Public commit and tag", "Public image", "Public and private releases"} {
if !strings.Contains(stepBody(t, job, step), "if: env.PUBLIC == 'true'") {
t.Errorf("%q does not wait for PUBLIC, so a dev push would publish it", step)
}
}
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")
export := stepBody(t, job, "Export, changelog and leak gate")
for _, want := range []string{"git archive HEAD", "ci/changelog.sh", `ci/leakgate.sh "${EXPORT}" "${RUNNER_TEMP}/changelog/public.md"`} {
if !strings.Contains(export, want) {
t.Errorf("the export step lacks %s\n%s", want, export)
}
}
gate := strings.Index(job, "- name: Export, changelog and leak gate")
for _, step := range []string{"Build and push", "Public commit and tag"} {
if at := strings.Index(job, "- name: "+step); at < gate {
t.Errorf("%q runs before the leak gate, so a leak could be pushed before it is caught", step)
}
}
for _, step := range []string{"Build and push", "Public image"} {
if !strings.Contains(stepBody(t, job, step), `"${EXPORT}"`) {
t.Errorf("%q does not build from the export, so export-ignored files reach its image", step)
}
}
image := stepBody(t, job, "Public image")
for _, want := range []string{"--provenance=false", "org.opencontainers.image.source=https://github.com/${PUBLIC_REPO}", "org.opencontainers.image.revision=${REVISION}"} {
if !strings.Contains(image, want) {
t.Errorf("the public image build lacks %s\n%s", want, image)
}
}
if !strings.Contains(job, "PUBLIC_REPO: Fabled-Sword/minstrel") {
t.Error("PUBLIC_REPO is not the public GitHub repository, so the release and its labels point elsewhere")
}
commit := stepBody(t, job, "Public commit and tag")
for _, want := range []string{"GIT_AUTHOR_EMAIL=amateurdungeoneer@fabledsword.com", "GIT_COMMITTER_EMAIL=amateurdungeoneer@fabledsword.com", "+0000", "git add -A -f"} {
if !strings.Contains(commit, want) {
t.Errorf("the public commit lacks %s\n%s", want, commit)
}
}
}