Skip to content

fix(promote-release): delete RC draft pre-releases by id and gate tag removal - #624

Merged
c-vigo merged 5 commits into
devfrom
bugfix/623-promote-release-rc-draft-cleanup
Jun 23, 2026
Merged

c-vigo merged 5 commits into
devfrom
bugfix/623-promote-release-rc-draft-cleanup

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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
  • 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)
    • 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

  • 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; skipped 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

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • 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

c-vigo added 3 commits June 23, 2026 07:45
Adds a bats spec and fixture for a select-rc-draft-releases helper that
enumerates RC draft pre-releases for a base version from a GitHub
releases list. The helper does not exist yet, so the spec fails (exit
127) and pins the contract for the cleanup fix.

Refs: #623
Enumerates RC draft pre-releases for a base version directly from the
GitHub releases list, emitting "<id>\t<tag>" for each draft pre-release
tagged X.Y.Z-rcN. Seeding from releases (not git tags) lets cleanup
delete drafts by id and reclaim drafts whose RC tag was already removed
by an earlier partial run.

Refs: #623
… removal

The cleanup step deleted RC draft pre-releases with `gh release delete
<tag>`, but that resolves the release via the get-release-by-tag API,
which never returns drafts -- so every delete failed while the code fell
through and deleted the git RC tag anyway. Because the loop was seeded
from `git ls-remote --tags`, the now-tagless draft became undiscoverable
and survived every later run, accumulating in the smoke-test repo.

Rework cleanup in both promote-release workflows:
- Seed from the releases list (not git tags), so drafts whose RC tag was
  already removed by an earlier partial run are reclaimed.
- Delete each RC draft pre-release by release id via the releases API.
- Delete a git RC tag only when no GitHub Release is still attached,
  preserving published pre-releases and keeping a failed-delete draft
  discoverable.
- Verify no RC draft pre-release survives and fail loudly if one does.

The upstream workflow uses the new bats-tested select-rc-draft-releases
helper; the self-contained workspace template inlines the same jq filter.

Refs: #623
@c-vigo c-vigo self-assigned this Jun 23, 2026
The image installs just from its latest release, which advanced to
1.54.0, so the pinned minor-version assertion (1.53.) failed in Image
Tests. Update the expectation to match.

Refs: #623
@c-vigo
c-vigo enabled auto-merge June 23, 2026 06:54
@c-vigo
c-vigo merged commit 304cfea into dev Jun 23, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/623-promote-release-rc-draft-cleanup branch June 23, 2026 07:00
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.

1 participant