Skip to content

Clean up stale release branch before Create Release PR retry#4035

Merged
amirejaz merged 1 commit intomainfrom
fix-create-release-pr-stale-branch-cleanup
Mar 6, 2026
Merged

Clean up stale release branch before Create Release PR retry#4035
amirejaz merged 1 commit intomainfrom
fix-create-release-pr-stale-branch-cleanup

Conversation

@amirejaz
Copy link
Contributor

@amirejaz amirejaz commented Mar 6, 2026

Summary

When the Create Release PR workflow fails after creating the release/vX.Y.Z branch but before opening the PR (e.g. helm-docs or file update failure), the branch remains. A retry fails with "Reference already exists" because releaseo cannot create the same branch again.

This change adds a pre-step that:

  1. Computes the target release branch from the VERSION file and bump_type input
  2. Checks whether there is an open PR for that branch
  3. Deletes the branch only when there is no open PR (treats it as stale from a failed run)
  4. Fails with an explanatory message when a release PR already exists, so the branch is not deleted

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Manually verified the cleanup logic: branch name derivation matches releaseo (release/v{major}.{minor}.{patch}), and gh pr list/gh api usage is valid.

Changes

File Change
.github/workflows/create-release-pr.yml Add "Clean up stale release branch" step before releaseo
.claude/skills/toolhive-release/references/WORKFLOW-REFERENCE.md Document the fix in troubleshooting

Does this introduce a user-facing change?

No. Improves workflow robustness for release automation only.

Special notes for reviewers

The cleanup step uses secrets.GITHUB_TOKEN (via GH_TOKEN) for gh CLI, separate from secrets.RELEASE_TOKEN used by releaseo. contents: write is sufficient for deleting refs.

@amirejaz amirejaz requested a review from JAORMX as a code owner March 6, 2026 12:32
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Mar 6, 2026
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.56%. Comparing base (3aefbc8) to head (3aadc6d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4035      +/-   ##
==========================================
- Coverage   68.62%   68.56%   -0.06%     
==========================================
  Files         444      444              
  Lines       45222    45222              
==========================================
- Hits        31034    31008      -26     
- Misses      11791    11817      +26     
  Partials     2397     2397              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amirejaz amirejaz merged commit e342c64 into main Mar 6, 2026
55 of 56 checks passed
@amirejaz amirejaz deleted the fix-create-release-pr-stale-branch-cleanup branch March 6, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants