Repository navigation
fix(promote-release): prune RC draft pre-releases in cleanup - #601
Merged
Merged
Conversation
The cleanup job deleted RC GHCR images/signatures and git RC tags, but skipped any tag with a GitHub Release attached. Adopters that dispatch candidates with create-release=true publish X.Y.Z-rcN draft pre-releases, so every cycle stranded a draft pre-release and its tag indefinitely. Delete RC draft pre-releases (draft && prerelease, tag matching ^X.Y.Z-rc[0-9]+$) before the tag, then let the existing no-release tag deletion remove the orphaned tag. Strictly guarded so published releases are never touched. Mirrored in the root workflow for parity. Refs: #600
c-vigo
added a commit
that referenced
this pull request
Jun 23, 2026
… removal (#624) ## Description `promote-release.yml` left RC **draft pre-releases** stranded in the smoke-test repo every release cycle (e.g. `0.3.7-rc1`, `0.3.8-rc1` are currently orphaned). The cleanup step (added in #601) identified each RC draft correctly but deleted it with `gh release delete <tag>`, which resolves the release via the *get-release-by-tag* API — an endpoint that never returns drafts. So the delete failed (`WARN: failed to delete RC draft pre-release …`), yet the code fell through and deleted the git RC tag anyway. Since the loop was seeded from `git ls-remote --tags`, the now-tagless draft became undiscoverable and survived every subsequent run. Root cause confirmed from the `0.3.8` promote run log in the smoke-test repo: ``` Deleting RC draft pre-release 0.3.8-rc1 (draft pre-release) WARN: failed to delete RC draft pre-release 0.3.8-rc1 Deleting remote tag 0.3.8-rc1 (no GitHub Release) ``` ## Type of Change - [ ] `feat` -- New feature - [x] `fix` -- Bug fix - [ ] `docs` -- Documentation only - [ ] `chore` -- Maintenance task (deps, config, etc.) - [ ] `refactor` -- Code restructuring (no behavior change) - [ ] `test` -- Adding or updating tests - [ ] `ci` -- CI/CD pipeline changes - [ ] `build` -- Build system or dependency changes - [ ] `revert` -- Reverts a previous commit - [ ] `style` -- Code style (formatting, whitespace) ### Modifiers - [ ] Breaking change (`!`) -- This change breaks backward compatibility ## Changes Made Rework the cleanup step in **both** promote-release workflows: - **`.github/scripts/select-rc-draft-releases.sh`** (new) — enumerates RC draft pre-releases for a base version from a GitHub releases list, emitting `<id>\t<tag>` for each `draft && prerelease` whose tag is `X.Y.Z-rcN`. Bats-tested. - **`.github/workflows/promote-release.yml`** — cleanup now: (1) seeds from the releases list, not git tags, so drafts whose RC tag was already removed by an earlier partial run are reclaimed; (2) deletes each RC draft by **release id** (works for drafts); (3) deletes a git RC tag only when no GitHub Release is still attached (preserves published pre-releases and keeps a failed-delete draft discoverable); (4) verifies no RC draft survives and fails loudly otherwise. Uses the new helper. - **`assets/workspace/.github/workflows/promote-release.yml`** — same fix; since consumer repos don't ship `.github/scripts`, the template inlines the equivalent jq filter. - **`tests/bats/select-rc-draft-releases.bats`** + **`tests/bats/fixtures/releases-list.json`** (new) — 8 cases covering selection, draft/prerelease/base filtering, malformed suffixes, and arg validation. - **`CHANGELOG.md`** / synced **`assets/workspace/.devcontainer/CHANGELOG.md`** — Fixed entry. ## Changelog Entry ### Fixed - **Stop promote-release cleanup from orphaning RC draft pre-releases** ([#623](#623)) - The cleanup step deleted RC draft pre-releases with `gh release delete <tag>`, which cannot resolve a draft, then deleted the git RC tag anyway — stranding the draft and making it undiscoverable on later runs (the loop was seeded from git tags) - Cleanup now enumerates RC draft pre-releases from the releases list, deletes them by release id, removes a git RC tag only when no release is attached, and fails loudly if any RC draft survives — also reclaiming drafts whose tag was already removed by an earlier partial run ## Testing - [x] Tests pass locally (`just test`) - [ ] Manual testing performed (describe below) ### Manual Testing Details - New bats suite passes (8/8); full bats suite green except the pre-existing `worktree.bats` tmux integration test (unrelated; `skip`ped in CI). - Simulated the new selection + tag-retention logic against `tests/bats/fixtures/releases-list.json`: RC drafts of the base are selected by id; published pre-releases and other base versions are retained; `HAS_RELEASE` correctly keeps tags that still have a release and deletes orphans. - shellcheck + yamllint clean on the changed files. ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly (edit `docs/templates/`, then run `just docs`) - [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and pasted the entry above) - [x] My changes generate no new warnings or errors - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published ## Additional Notes The two already-orphaned drafts (`0.3.7-rc1`, `0.3.8-rc1`) in `vig-os/devcontainer-smoke-test` are not removed by this PR; the next final promote will reclaim them now that cleanup seeds from the releases list, or they can be deleted manually. Refs: #623
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.
Description
Closes #600. The
promote-release.ymlcleanup job pruned RC GHCR images/signatures and git RC tags, but skipped any tag with a GitHub Release attached. Adopters that dispatch candidates withcreate-release=true(the smoke-test repo) publishX.Y.Z-rcNdraft pre-releases, so every release cycle stranded a draft pre-release and its tag indefinitely.Type of Change
fix-- Bug fixChanges Made
In the cleanup step of both promote-release workflows, change the per-tag decision from "release exists → skip" to:
draft == true && prerelease == trueand the tag matches^${VERSION}-rc[0-9]+$→ delete it viagh release delete "$tag" --yes, then fall through to the existing tag-deletion (gh api -X DELETE .../git/refs/tags/${tag}).Strictly guarded so a published release can never be deleted. Reuses the existing
retrywrapper,jqmatching, logging style, and tag-deletion call — no new step.Files:
assets/workspace/.github/workflows/promote-release.yml— adopter-facing SSoT (what smoke-test consumes).github/workflows/promote-release.yml— root, mirrored for parity (root's candidate path doesn't create RC drafts today)Changelog Entry
Fixed
X.Y.Z-rcNdraft pre-releases (and their now-orphaned tags); guarded to never touch published releasesTesting
Manual Testing Details
The cleanup logic is shell embedded inline in workflow YAML (GitHub API calls), so it is not unit-testable without a refactor the issue does not ask for. Validated by:
-rcfoodraft → skip (regex guard); no release → delete tag — all correct.End-to-end verification is the next release run in
vig-os/devcontainer-smoke-test(dispatches candidates withcreate-release=true): confirm theX.Y.Z-rcNdraft pre-release + tag are pruned and the publishedX.Y.Zrelease is untouched.Checklist
CHANGELOG.mdin the[Unreleased]section (and pasted the entry above)