-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(scripts): exclude RC tags from dogfood version resolution #24175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,19 +43,32 @@ if ! echo "$release_branches" | grep "release/2.26" >/dev/null; then | |
| error "Could not find existing release branches. Did you run 'git fetch -ap ${remote}'?" | ||
| fi | ||
|
|
||
| latest_release_branch=$(echo "$release_branches" | tail -n 1) | ||
| latest_release_branch_version=${latest_release_branch#release/} | ||
| log "Latest release branch: $latest_release_branch" | ||
| log "Latest release branch version: $latest_release_branch_version" | ||
| # Step 2: Iterate from the latest release branch backwards to find the deploy | ||
| # branch. A release branch is the deploy target if its `.0` tag does not yet | ||
| # exist (i.e. the release is in progress / frozen). Release branches that only | ||
| # carry RC tags (v<x.y>.0-rc.*) are skipped — they are not considered frozen. | ||
| for branch in $(echo "$release_branches" | sort -Vr); do | ||
| version=${branch#release/} | ||
| log "Checking release branch: $branch (version: $version)" | ||
|
|
||
| # Step 2: check if a matching tag `v<x.y>.0` exists. If it does not, we will | ||
| # use the release branch as the deploy branch. | ||
| if ! git rev-parse "refs/tags/v${latest_release_branch_version}.0" >/dev/null 2>&1; then | ||
| log "Tag 'v${latest_release_branch_version}.0' does not exist, using release branch as deploy branch" | ||
| deploy_branch=$latest_release_branch | ||
| else | ||
| log "Matching tag 'v${latest_release_branch_version}.0' exists, using main as deploy branch" | ||
| fi | ||
| if git rev-parse "refs/tags/v${version}.0" >/dev/null 2>&1; then | ||
| # Final .0 tag exists — this release (and all older ones) are done. | ||
| log "Tag 'v${version}.0' exists, release is complete" | ||
| break | ||
| fi | ||
|
|
||
| # No .0 tag. Check if there are RC tags, which would indicate this is | ||
| # an RC-only branch that we should skip. | ||
| if git tag -l "v${version}.0-rc.*" | grep -q .; then | ||
| log "Branch '$branch' only has RC tags, skipping" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit Log says |
||
| continue | ||
| fi | ||
|
|
||
| # No .0 tag and no RC tags — this is the frozen release branch. | ||
| log "Branch '$branch' is the frozen release branch" | ||
| deploy_branch=$branch | ||
| break | ||
| done | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 When the loop exhausts without finding a frozen branch (every candidate was either released or RC-only), done
if [[ "$deploy_branch" == "main" ]]; then
log "No frozen release branch found, falling back to main"
fi |
||
| log "Deploy branch: $deploy_branch" | ||
|
|
||
| # Finally, check if the current branch is the deploy branch. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 The RC-tag check couples this deploy logic to a tagging convention that is being retired ("no RC branches moving forward"). Going forward, the
git tag -lbranch on line 62 is effectively dead code that never triggers — but a future reader has to understand a defunct workflow to reason about correctness.Consider an approach that doesn't depend on RC tags at all: find the latest released branch (has
.0tag), then check whether the next branch in version order exists:This expresses the real invariant directly ("frozen = the branch after the latest released one") rather than inferring it by elimination. No coupling to RC conventions, fewer git calls in the loop, and the logic stays correct whether RC tags exist or not.
Also a nit on this line:
$release_branchesis alreadysort -V'd on line 38.tacwould be clearer — "same list, reversed" rather than re-sorting.