Guard release.sh against tagging the wrong commit#35
Merged
Conversation
release.sh tagged whatever was checked out, so running it from a feature branch would silently tag the wrong commit. Before tagging, require a clean working tree, fetch, switch to main, and fast-forward to origin/main — failing loudly rather than switching over uncommitted work or force-updating over diverged state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
release.shtagged whatever commit was checked out, so running it from a feature branch would silently tag the wrong commit (and build/publish it).Change
Before tagging, the script now:
git fetch origin --tags— gets the real remote state (also ensures current-version detection sees the latest tags).mainand fast-forwards toorigin/main— aborts with a clear message if it can't fast-forward (diverged/ahead), rather than force-updating.It fails loudly on unexpected state instead of doing something destructive. This hard-codes "releases come from
main", which matches the existing workflow (PRs target main; the release workflow builds from the tag).Testing
bash -n release.shpasses. Guard logic is standard git plumbing; the tag/push/confirm flow is unchanged.🤖 Generated with Claude Code
Summary by cubic
Guard
release.shto always tag an up-to-datemainand fail fast on dirty or diverged state, preventing accidental releases from feature branches.git fetch origin --tagsto sync remote state.mainand fast-forward toorigin/main(--ff-only), aborting if not possible.Written for commit 3ac50c1. Summary will update on new commits.