fix: select the release tag by version instead of by tagged commit - #567
Merged
Conversation
The release job computed an already-released tag and failed with "tag_name was used by an immutable release". tag-version.sh read the latest version with `git describe --tags $(git rev-list --tags --max-count=1)`, which names whichever tag git happens to find on the newest tagged commit. Several tags share that commit - 2.0.256, 2.0.257 and v2 all point at f6ecd22, and update-v2-tag force-moves v2 onto every release commit, so a collision is structural rather than a one-off. describe returned 2.0.256, the bump produced 2.0.257, and that release already existed. Select the highest version tag with `sort -V` instead. The glob also keeps the legacy v-prefixed tags out of the running, which removes the v-stripping branch that would have turned v1.111 into 1.111.1. Add `set -eo pipefail` so this fails at the point it breaks: without it the rejected `git tag`/`git push` still exited 0 and exported the unused tag, surfacing two steps later as a confusing 422. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| OSS Licenses | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
There was a problem hiding this comment.
Pull request overview
This PR hardens the release-tagging script to select the next release tag based on semantic version ordering (rather than “newest tagged commit”), and to fail fast when tag creation/push fails—preventing accidental re-use of an existing release tag.
Changes:
- Switch latest-version detection from
git describeon the newest tagged commit to version-based selection from the tag list. - Add
set -eo pipefailand a guard for an empty tag list so failures surface at the correct step. - Quote tag/output variables and force-refresh tags from the remote.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3
to
+5
| # Fail the step if the tag cannot be created or pushed. Without this, a rejected | ||
| # `git push` still exits 0 and the release step goes on to use a tag that was | ||
| # never created. |
Comment on lines
+12
to
17
| latest_tag=$(git tag -l '[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -1) | ||
|
|
||
| if [[ -z $latest_tag ]]; then | ||
| echo "No version tag found; refusing to guess the next version" >&2 | ||
| exit 1 | ||
| fi |
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.
Problem
The release job on develop failed after #566 merged (run):
2.0.257 was already released on 08-06.
tag-version.shrecomputed it because three tags point at the same commitf6ecd22:It read the latest version with
git describe --tags $(git rev-list --tags --max-count=1)— whichever tag git happens to name on the newest tagged commit. With several tags on one commit that pick is arbitrary; it returned2.0.256, bumped to2.0.257, and that release already existed. This is structural rather than a one-off:update-v2-tagforce-movesv2onto every release commit, so the newest release commit always carries a second tag.A second bug hid the first: with no
set -e, the rejectedgit tag/git pushstill exited 0 and exportedNEW_TAG=2.0.257anyway, so the step went green and the failure surfaced two steps later as a confusing 422.Nothing to do with #566 — any push touching
src/,dist/,scripts/,package*.jsonoraction.ymlwould have failed the same way.Change
git tag -l '[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -1) instead of by tagged commit. The glob also keeps the legacyv-prefixed tags (v2,v1.111,v2-lite) out of the running, which removes thev-stripping branch that would have turnedv1.111into1.111.1.set -eo pipefailso a rejected tag or push fails the step where it breaks.Verification
Reproduced the three-tags-on-one-commit state in a scratch repo:
0.1.0— arbitrary pick, confirming the ambiguity2.0.257→ next tag2.0.258bash -nclean.Note
The failed run died before
npm run update-v2-tag, sov2still points atf6ecd22— the payload change from #566 is on develop but not yet live for@v2consumers. Merging this withauto-deploycuts2.0.258and movesv2forward, which ships it.🤖 Generated with Claude Code
✨ PR Description
Purpose: Fix release tag selection to use semantic version ordering instead of commit recency, preventing incorrect version increments.
Main changes:
git describewithgit tag -landsort -Vfor version-based tag selection instead of commit-basedset -eo pipefailand validation check for missing tagsChangelog
✨ New Features
🔧 Improvements
Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how