Skip to content

fix(ci): a pre-release tag must not publish latest to GHCR - #2499

Merged
obasilakis merged 1 commit into
devfrom
fix/publish-images-rc-latest
Sep 2, 2026
Merged

obasilakis merged 1 commit into
devfrom
fix/publish-images-rc-latest

Conversation

@obasilakis

Copy link
Copy Markdown
Contributor

Prerequisite for cutting v0.9.5-rc1. Refs #2281, #2471 (the marketplace snapshot needs GHCR images from an RC tag).

The bug

publish-images.yml gates its latest rule on the tag ref's prefix alone:

type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}

refs/tags/v0.9.5-rc1 satisfies startsWith(refs/tags/v). So pushing a release candidate republishes latest, and every unpinned hosted install pulls the RC on its next start.sh --hosted.

The workflow already argues against precisely this outcome, twelve lines above — "a workflow_dispatch smoke build must never silently become what every hosted install pulls". The dispatch door was closed; the pre-release tag door was not.

It bites now rather than hypothetically: an RC is the prerequisite for the DigitalOcean snapshot. #2471's own sequencing is cut a tag → publish-images.yml fires → packer build -var image_tag=<tag>. The tag exists specifically to be built from before the payload is blessed, which makes it the one tag that must not become the default pull.

The fix

-type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
+type=raw,value=latest,enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-') }}

Two things worth a reviewer's attention:

Why not let metadata-action handle it. It does handle it — for type=semver. Its documented rule is "Pre-release (rc, beta, alpha) will only extend {{version}} … as tag", which is why {{major}}.{{minor}} on line 183 is already safe and correctly carries no guard of its own. That rule has no effect whatsoever on a type=raw value, so the exclusion has to be written into the enable: expression. A test pins that asymmetry in both directions, because "add the guard everywhere" is the natural wrong fix.

Why - and not an rc/beta/alpha list. The hyphen is the semver prerelease rule (spec item 9: a prerelease is a hyphen plus dot-separated identifiers after patch). A spelling list goes stale the first time someone tags -pre or -canary.

{{version}} and v{{version}} are deliberately untouched — an RC must stay pullable by its exact tag. Only the mutable pointer is withheld.

Verification

  • tests/unit/test_2471_publish_images_prerelease_latest.py — 4 tests, all passing. Verified to actually catch the bug: reverting the one-line change fails test_latest_excludes_prerelease_tags; the other three still pass, so the negative case is the one being asserted.
  • The suite covers the regression in both directions: the exclusion is present on latest, the two pre-existing dispatch guards survive, and the exclusion is absent from {{version}}/v{{version}}/{{major}}.{{minor}}.
  • yaml.safe_load on the workflow — parses.
  • Not verified: an actual tag push. The expression is evaluated by Actions, not locally, and the only honest test of it is the RC push this unblocks.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K9bL6DZ8QVyrSvPybp5ZuK

`publish-images.yml` gated its `type=raw,value=latest` rule on
`startsWith(github.ref, 'refs/tags/v')`. That expression answers "is this a
version tag", not "is this a version anyone should be running", so pushing a
release candidate (`v0.9.5-rc1`) would move `latest` and every unpinned hosted
install would pull the RC on its next `start.sh --hosted`.

This is the hazard the workflow already documents one paragraph above — it
guards `workflow_dispatch` against exactly this, and the same door was left
open for pre-release tag pushes. It matters now because an RC is the
prerequisite for the DigitalOcean snapshot (#2281/#2471): the marketplace
build needs GHCR images from a tag cut BEFORE the payload is blessed, which
makes the RC the one tag that must never become the default pull.

The `-` test IS the semver prerelease rule (spec item 9), so it needs no list
of rc/beta/alpha spellings to keep current. It cannot be delegated to
metadata-action: its documented prerelease handling ("pre-release will only
extend {{version}}") applies to `type=semver` entries — which is why
`{{major}}.{{minor}}` needs no guard of its own — and has no effect at all on
a `type=raw` value.

`{{version}}` and `v{{version}}` are deliberately untouched: an RC must stay
pullable by its exact tag, which is the whole point of cutting one. Only the
mutable pointer is withheld.

Guarded by tests/unit/test_2471_publish_images_prerelease_latest.py — verified
to fail against the pre-fix expression.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01K9bL6DZ8QVyrSvPybp5ZuK

@dolho dolho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/review Report

Scope: CLEAN — one expression edit + its four-directional guard test. Every technical claim in the PR body checks out against the tree:

  • The bug is real and the fix is complete. refs/tags/v0.9.5-rc1 satisfies startsWith(refs/tags/v), and — the part I went to verify — the type=raw line is the only latest producer: the workflow already pins flavor: latest=false (line 148, with its own comment explaining that latest=auto would have made any raw-line gating inert). So !contains(github.ref_name, '-') closes the whole surface; there is no second door.
  • The metadata-action asymmetry is stated correctly. Its prerelease rule ("pre-release will only extend {{version}}") governs type=semver only — {{major}}.{{minor}} is safe with no guard, and a guard there would be the "natural wrong fix" the fourth test pins against. Asserting the absence of the guard on the semver lines is the best part of the test file: it stops the next person from "completing" the fix into a regression.
  • The hyphen test is the right predicate. SemVer item 9: prerelease = hyphen + identifiers after patch; build metadata uses +, which this correctly leaves alone. No spelling list to rot.
  • Trigger reachability: on: push: tags: matches v*, so an RC tag does fire the workflow — the guard is what stands between it and latest, exactly as described.
  • Test hygiene: _latest_line skips comment lines (the new comment block above the rule would otherwise be a false match surface), asserts exactly one rule, and the PR verified the negative case by reverting the fix — the assertion that actually matters.

Findings: none, critical or informational. The claims that can only be proven by an Actions evaluation (github.ref_name at tag-push time) are honestly listed as unverified, and trinity-dev#20's Step 9 digest check is the runtime verification for exactly that residual — the pairing is right.

Approving. Sequencing note for the merger: this must land before any RC tag is pushed; trinity-dev#20's Step 2.12 blocker enforces that ordering at run time as well.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NLfHNPtB5UCMk4LonZiJux

@obasilakis
obasilakis merged commit 769dca2 into dev Sep 2, 2026
30 of 32 checks passed
vybe pushed a commit that referenced this pull request Sep 2, 2026
… (tag-only cut off dev) (#2502)

trinity-dev 406c390: a hyphenated tag (v0.9.5-rc1) now takes a tag-only
path off dev — no dev→main merge, no release PR, no Closes block, no
issue sweep — and Step 9 verifies publish-images.yml for both modes.
Companion to #2499, which withholds `latest` from a
pre-release tag; the playbook's new Step 2.12 blocker checks for it.

The bump is load-bearing rather than housekeeping: a `/release
v0.9.5-rc1` run from the pinned checkout would execute v1.5, which has
no RC mode and would treat the tag as a full cut — the dev→main merge
and the status-in-dev sweep that v1.6 exists to prevent.

Also carries the 13 intervening trinity-dev commits (debt-inbox entries
and the /sprint `--base dev` fix from #2476).

Refs #2281.


Claude-Session: https://claude.ai/code/session_012d5K93m76zw4Rn193FXvsJ

Co-authored-by: sim <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
obasilakis added a commit that referenced this pull request Sep 2, 2026
…n}}` (+ VERSION 0.9.5-rc2) (#2505)

* fix(ci): the v-prefixed image alias must be {{raw}}, not v{{version}}

`v{{version}}` is a COMPONENT pattern, so docker/metadata-action drops it for a
pre-release under the same documented rule that correctly drops
`{{major}}.{{minor}}`: "Pre-release (rc, beta, alpha) will only extend
{{version}} (or {{raw}} if specified) as tag". `{{raw}}` is the documented
exception and keeps the `v`.

Observed on v0.9.5-rc1: all five packages published `0.9.5-rc1` and
`sha-0f4d54d`, and NO `v0.9.5-rc1`.

That is not cosmetic — it broke the marketplace build outright, which is the
one thing the RC was cut for. `packer/digitalocean/scripts/01-provision.sh`
feeds a single `TRINITY_IMAGE_TAG` to two consumers that need different
strings once they diverge:

    line 86:  git clone --depth 1 --branch "${TRINITY_IMAGE_TAG}"   -> v0.9.5-rc1
    line 93:  docker pull ghcr.io/abilityai/trinity-*:${TAG}        -> 0.9.5-rc1

They are the same string only while this alias exists, so its absence leaves
NO value of `image_tag` able to build the snapshot. #2280's own comment
predicted the failure ("makes the release name and the image tag the same
string, which is what anyone reading the releases page will type") — it just
did not account for the pre-release rule silently removing the alias.

`{{version}}` and `{{major}}.{{minor}}` are untouched: the first is what a
prerelease extends, the second is correctly withheld from one.

Guarded by tests/unit/test_2471_publish_images_prerelease_latest.py (extended
from the #2499 suite) — verified to fail against the pre-fix expression.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01K9bL6DZ8QVyrSvPybp5ZuK

* chore: set version to 0.9.5-rc2

Rides this PR rather than its own: `dev` is protected, so every write costs a
review cycle, and both changes are prerequisites for the same rc2 cut with the
same reviewer. The playbook already batches release-prep writes onto one
`chore/release-<semver>` branch (Step 4 + Step 6a) — splitting them here was
ceremony, not safety.

rc2 rather than a re-cut of rc1: an RC tag is immutable by the playbook's own
rule, because a snapshot built from it may already sit in a vendor queue.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01K9bL6DZ8QVyrSvPybp5ZuK

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
webmixgamer added a commit that referenced this pull request Sep 2, 2026
)

Review artifacts from validating the publish-images `{{raw}}` alias fix:

- docs/memory/learnings.md: a tag-push-only workflow is never exercised
  by PR CI, so audit every sibling tag rule against the metadata-action
  pre-release rule and verify against the live registry after the first
  RC push (the #2499 -> #2505 incomplete-fix chain).
- docs/security-reports/cso-diff-2026-09-02-2505-*: diff-scoped CSO
  audit, zero findings; four docker/* action SHA pins verified against
  their version tags.

Refs #2281

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants