Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions scripts/patch-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Examples:

Prerequisites:
- GitHub CLI (gh) must be installed and authenticated
- User must have "bypass branch protection" permissions on release branches
EOF
}

Expand Down Expand Up @@ -335,26 +334,14 @@ main() {
fi
echo

# Step 4: Check if release is necessary.
# Step 4: Determine branch ref and validate patch number.
# In dry-run mode, use the remote branch ref since we didn't create the worktree.
local branch_ref="HEAD"
if [[ "$DRY_RUN" == "true" ]]; then
branch_ref="origin/${release_branch}"
log_info "(Using origin/${release_branch} for dry-run checks)"
fi

local head_commit_msg
head_commit_msg=$(git log -1 --format='%s' "$branch_ref")

if [[ "$head_commit_msg" =~ ^Release\ [0-9]+\.[0-9]+\.[0-9]+$ ]]; then
log_warn "Tip of $release_branch is already a release commit: $head_commit_msg"
if ! confirm "Create another release commit on top?"; then
log_info "Aborted by user."
exit 0
fi
echo
fi

Comment on lines -346 to -357

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this check?

if [[ "$patch_number" != "$expected_patch" ]]; then
log_warn "Patch number $patch_number is not sequential."
log_warn "Latest tag: ${latest_tag:-none}"
Expand Down Expand Up @@ -443,13 +430,14 @@ main() {
echo
fi

# Step 8: Create release commit and tag.
log_info "Creating release commit and tag..."
# Step 8: Create release tag on the current HEAD of the release branch.
# Note: this intentionally does NOT create a new commit. Tagging HEAD directly
# avoids pushing a commit to the protected release branch, so no "bypass branch
# protection" permission is required (see ROX-36649).
Comment on lines +434 to +436

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You documenting planning and historical steps, not augmenting the code to facilitate readability.

log_info "Creating release tag..."
if [[ "$DRY_RUN" == "true" ]]; then
log_dry_run "git commit --allow-empty -m \"Release ${version}\""
log_dry_run "git tag --annotate --no-sign ${version}"
else
git commit --allow-empty -m "Release ${version}"
git tag --annotate --no-sign "${version}" -m "${version}"
fi
echo
Expand All @@ -473,13 +461,12 @@ main() {
echo
fi

# Step 10: Push.
if ! confirm "Push tag and commits to origin? (Requires bypass branch protection)" "y"; then
# Step 10: Push the tag.
if ! confirm "Push tag to origin?" "y"; then
log_info "Aborted by user."
log_info "To push manually, run from the worktree directory:"
log_info " cd ${WORKTREE_DIR}"
log_info " git push origin ${version}"
log_info " git push --set-upstream origin ${release_branch}"
log_info ""
log_info "To clean up the worktree afterwards:"
log_info " cd ${ORIGINAL_REPO_ROOT}"
Expand All @@ -490,13 +477,11 @@ main() {
exit 0
fi

log_info "Pushing tag and commits..."
log_info "Pushing tag..."
if [[ "$DRY_RUN" == "true" ]]; then
log_dry_run "git push origin ${version}"
log_dry_run "git push --set-upstream origin ${release_branch}"
else
git push origin "${version}"
git push --set-upstream origin "${release_branch}"
fi
echo

Expand Down
Loading