How to Roll Back a Bad Release in GitHub Actions
gh release delete with --cleanup-tag removes a broken release and its tag, and gh release edit --latest can re-point the latest badge to the last good version.
Take the bad tag as input, run gh release delete <tag> --cleanup-tag --yes, then optionally mark the previous good release as latest. Trigger it from workflow_dispatch.
Steps
- Accept the bad tag and the previous good tag as inputs.
- Delete the release and its tag with
gh release delete --cleanup-tag. - Re-mark the previous release as
--latest.
Workflow
.github/workflows/release.yml
on:
workflow_dispatch:
inputs:
bad_tag:
required: true
good_tag:
required: true
permissions:
contents: write
jobs:
rollback:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
gh release delete "${{ inputs.bad_tag }}" --cleanup-tag --yes
gh release edit "${{ inputs.good_tag }}" --latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}Gotchas
- Deleting a tag does not unpublish artifacts already pulled by users; yank the package separately.
--cleanup-tagremoves the git tag too; omit it to keep the tag and delete only the release.
Related guides
How to Promote a Pre-Release to Stable in GitHub ActionsFlip a GitHub pre-release to a stable release in GitHub Actions with gh release edit --prerelease=false and -…
How to Gate a Release on Manual Approval in GitHub ActionsPause a release job for human sign-off in GitHub Actions with a protected environment and required reviewers,…