Skip to content

fix(promote-release): prune RC draft pre-releases in cleanup - #601

Merged
c-vigo merged 1 commit into
devfrom
bugfix/600-promote-cleanup-rc-drafts
Jun 19, 2026
Merged

c-vigo merged 1 commit into
devfrom
bugfix/600-promote-cleanup-rc-drafts

Conversation

@c-vigo

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

Copy link
Copy Markdown
Contributor

Description

Closes #600. The promote-release.yml cleanup job pruned 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 (the smoke-test repo) publish X.Y.Z-rcN draft pre-releases, so every release cycle stranded a draft pre-release and its tag indefinitely.

Type of Change

  • fix -- Bug fix

Changes Made

In the cleanup step of both promote-release workflows, change the per-tag decision from "release exists → skip" to:

  • If the matched release is draft == true && prerelease == true and the tag matches ^${VERSION}-rc[0-9]+$ → delete it via gh release delete "$tag" --yes, then fall through to the existing tag-deletion (gh api -X DELETE .../git/refs/tags/${tag}).
  • Otherwise (published / non-prerelease / non-matching) → skip, untouched.
  • No release → delete the tag (unchanged).

Strictly guarded so a published release can never be deleted. Reuses the existing retry wrapper, jq matching, 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

  • Prune RC draft pre-releases in promote cleanup (#600)
    • Cleanup now deletes X.Y.Z-rcN draft pre-releases (and their now-orphaned tags); guarded to never touch published releases

Testing

  • Tests pass locally (pre-commit + YAML parse clean)
  • Manual testing performed (describe below)

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:

  • YAML parses for both files; all pre-commit hooks pass.
  • Simulated the decision logic across five cases — RC draft prerelease → delete; published prerelease → skip; published final → skip; stray -rcfoo draft → 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 with create-release=true): confirm the X.Y.Z-rcN draft pre-release + tag are pruned and the published X.Y.Z release is untouched.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • 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 (N/A — inline workflow shell; verified via simulation + next release run)

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
c-vigo merged commit 1fd166b into dev Jun 19, 2026
14 checks passed
@c-vigo
c-vigo deleted the bugfix/600-promote-cleanup-rc-drafts branch June 19, 2026 07:54
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
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