Repository navigation
fix: build release images and stop :latest racing - #380
Merged
Merged
Conversation
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #379.
The bug, in one line
Production served
0.8.9.dev0whilemainsaid0.8.9, and there was no versioned image to roll back to because none has been published since 0.6.2.Two independent causes, both verified
1. A release does not emit a tag
push.docker-build.ymltriggered only onpush, so it never ran for a release. The single workflow run on thev0.8.9ref wasPublish to PyPI, withevent: release-- andpublish.ymlis the one workflow that already listedreleaseamong its triggers, which is why it was also the only one that fired.That is the whole reason the versioned tags are missing. Every named tag on the package today:
The other 192 are
sha-*. So 0.7.x and all of 0.8.x produced no rollback target.2.
:latestwas written by a race. The workflow had noconcurrency:guard and wrote:lateston every default-branch push. The 0.8.9 release pushed two commits tomainten seconds apart and both built:Both wrote
:latest, one second apart, with no ordering between them. Production running0.8.9.dev0through eleven hours of hourly auto-updates is the evidence of which one won.The fix
release: [published]added to the triggers, so a release builds its images. Thepush/tagstrigger stays for a tag pushed by hand.concurrency:keyed on the ref,cancel-in-progress: false. Two pushes to the same ref serialize instead of interleaving their tag writes. Never cancel: a cancelled run can be one already pushing layers.:latestnow means the latest RELEASE, not the head ofmain. Production pulls:latest(deploy/auto-update.sh), so this is what decides what it serves.:mainstill follows the branch for anyone who wants that.workflow_dispatchadded, so a maintainer can rebuild a tag:gh workflow run docker-build.yml --ref v0.8.9. That is also the recovery path for releases that predate this fix.deploy/DEPLOYMENT_ARCHITECTURE.mdgains a table saying what each tag means and when it moves, since "latest" no longer means what a reader would assume.Behavior change worth calling out
Pushing to
mainno longer updates production. Publishing a release does. That is the intended reading of "promote to production" and it is what makes a promotion reversible, but it is a real change: a hotfix committed straight tomainwill not deploy until it is released, or until someone points the host at:main.Two things this PR does not do
:latestis still the0.8.9.dev0build until either a new release is published or someone runs the dispatch above againstv0.8.9. Rebuilding a tag pushes to the production image tag, so that is a deploy and I have not run it.main. Workflows forreleaseevents run from the default branch, so this needs the normal develop -> main path first.workflow_dispatchworks from any ref immediately.Testing
actionlintis clean, the YAML parses, and all four triggers plus the concurrency block are present. Thepull_requesttrigger and thebuild-and-testgate are untouched, so PR builds behave exactly as before -- this PR's own checks exercise that path.Review round
All findings addressed in
7e60eb9. One was a defect that would have reproduced the very bug this PR exists to fix.Critical: a pre-release would have moved
:latestThis workflow subscribes to the release event's
publishedtype, and GitHub firespublishedfor pre-releases too. My first expression was:So ticking "pre-release" on a release, or pushing
v1.2.3-rc1, would have moved:latest-- and production pulls:latesthourly. A release candidate would have deployed itself. That is the same failure this PR was written to prevent, moved one step earlier.Worse, it was internally inconsistent:
type=semverdeliberately does not move{{major}}.{{minor}}for a pre-release, so the workflow already had the protection one block up and I did not apply it to the raw tag.While fixing it I found a second hole of my own. The obvious repair still leaks:
A maintainer can tick "pre-release" on a tag with no hyphen in it. The payload says pre-release; the tag name gives no hint; the second clause waves it through on the very event whose own payload said not to. The second clause now excludes the release event, so on a release the payload decides and nothing else gets a vote.
Important: concurrency did not order across different releases
Keying on
github.refputs two releases published minutes apart into two groups. A slowv1.2.3finishing afterv1.2.4leaves:lateston the older one -- last-writer-wins again, just needing two releases instead of two commits. Every tag and release build now shares one group; branch builds stay per-branch, sincemainanddevelopwrite different tags.Important: workflow-level concurrency would have queued PR builds
cancel-in-progress: falseacross the whole workflow meant consecutive pushes to an open PR queued behind each other, including a container build and a 60s health-check loop, where before they ran independently. My "never cancel, a cancelled run can be pushing layers" reasoning is true forbuild-and-pushand false forbuild-and-test, which never touches the registry. Nowcancel-in-progress: ${{ github.event_name == 'pull_request' }}.Moderate: my root cause was wrong
I wrote that a release creates its tag inline and emits no tag push. Real behavior in general, not what happens here.
tag-release.ymlpushes the tag itself at line 64, after anactions/checkout@v4with notoken:override -- so it is authored by the defaultGITHUB_TOKEN, and GitHub does not start workflow runs from events that token created. The release in the same job is seen only becausegh release createruns underCI_ADMIN_TOKEN, a PAT (line 104). That asymmetry is the whole bug, and it means anything else added to this pipeline that must trigger a workflow has to be authored by the PAT. Corrected in the workflow comment, in the deployment doc, and on issue #379.Moderate: "runs from the default branch" conflated two things
For a
releaseeventGITHUB_SHAis the tagged commit, not main's tip, so the build content is correct. The real constraint is that theon:triggers are only honored once the file is on the default branch. Both statements are now separate, and I have dropped the claim thatworkflow_dispatchis an immediately available escape hatch -- it needs the same merge first.Moderate: two docs claimed main auto-deploys
CLAUDE.mdandCONTRIBUTING.mdboth saidmainauto-deploys to production. Both updated.Tests
tests/test_latest_tag_policy.pyis new and reads theenable=expression out of the workflow file rather than restating it, so editing the workflow re-runs these cases against the new expression instead of diverging from a copy. Its evaluator models only the operators the expression is allowed to use and asserts on anything else, so a change reaching for a new construct fails loudly rather than being mis-evaluated.Ten event shapes: pushes to main and develop, hand-pushed stable and rc tags, stable release, pre-release, pre-release whose tag has no hyphen, dispatch against a tag and against a branch, and a pull request.
Mutation-checked, each applied and reverted:
enable={{is_default_branch}}actionlintclean,ruff checkandruff formatclean.