Create release branches for minor versions#159
Conversation
WalkthroughIntroduces two new automation tools for release management: a GitHub Actions workflow that creates release branches from version tags, and a Bash script for cherry-picking merged PRs into release branches. Additionally, golangci-lint is updated to v2.10 and Kubernetes test binary version is bumped to 1.35.0. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/create-release-branch.yml (1)
1-22: Consider handling the case where the release branch already exists.The workflow will fail if the release branch already exists (e.g., if someone re-pushes a tag or if a branch was manually created). Consider either:
- Adding a check before creating the branch
- Using
git push --force-with-lease(if overwriting is acceptable)- Gracefully skipping if the branch exists
Additionally, the default checkout is a shallow clone which should work fine here since you're only creating a branch at HEAD.
💡 Optional: Add branch existence check
- name: Create release branch run: | TAG="${GITHUB_REF#refs/tags/}" # Extract major.minor from tag (e.g. v0.1.0 -> release-v0.1) BRANCH="release-${TAG%.*}" + if git ls-remote --exit-code --heads origin "${BRANCH}" &>/dev/null; then + echo "Branch ${BRANCH} already exists, skipping creation" + exit 0 + fi git switch -c "${BRANCH}" git push origin "${BRANCH}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/create-release-branch.yml around lines 1 - 22, The workflow currently creates a new branch with BRANCH="release-${TAG%.*}" using git switch -c and will fail if that branch already exists; update the step to first check remote for the branch (e.g., use git ls-remote --heads origin "${BRANCH}") and if found either skip creation (exit 0/print message) or switch to the existing branch (git switch "${BRANCH}"), or alternatively push with safe overwrite using git push --force-with-lease origin "${BRANCH}" depending on desired behavior; ensure TAG/BRANCH variables and the git switch -c / git push origin commands are updated accordingly to handle the existing-branch case gracefully.hack/cherry-pick.sh (1)
60-70: Consider saving and restoring the original branch.The script switches to a new branch but doesn't return the user to their original branch after completion (or on certain failure paths). This could be surprising for users.
💡 Optional: Save and restore original branch
+# Save current branch to restore later +ORIGINAL_BRANCH=$(git rev-parse --abbrev-ref HEAD) + # Fetch latest remote state git fetch origin "${RELEASE_BRANCH}"Then at the end (and optionally in error paths):
echo "" echo "Done." + +# Return to original branch +git switch "${ORIGINAL_BRANCH}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hack/cherry-pick.sh` around lines 60 - 70, Save the current branch before creating/switching to CHERRY_PICK_BRANCH by capturing the output of git rev-parse --abbrev-ref HEAD (e.g., ORIGINAL_BRANCH) and add a cleanup function that switches back to that branch; register it with trap to run on EXIT/ERR so the script returns the user to ORIGINAL_BRANCH on success or failure, and only attempt the switch-back if ORIGINAL_BRANCH is not the same as CHERRY_PICK_BRANCH and is not "HEAD" (detached); update the section around the git switch -c "origin/${RELEASE_BRANCH}" to use this saved ORIGINAL_BRANCH and ensure the trap/cleanup is installed immediately after capturing ORIGINAL_BRANCH.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/create-release-branch.yml:
- Around line 1-22: The workflow currently creates a new branch with
BRANCH="release-${TAG%.*}" using git switch -c and will fail if that branch
already exists; update the step to first check remote for the branch (e.g., use
git ls-remote --heads origin "${BRANCH}") and if found either skip creation
(exit 0/print message) or switch to the existing branch (git switch
"${BRANCH}"), or alternatively push with safe overwrite using git push
--force-with-lease origin "${BRANCH}" depending on desired behavior; ensure
TAG/BRANCH variables and the git switch -c / git push origin commands are
updated accordingly to handle the existing-branch case gracefully.
In `@hack/cherry-pick.sh`:
- Around line 60-70: Save the current branch before creating/switching to
CHERRY_PICK_BRANCH by capturing the output of git rev-parse --abbrev-ref HEAD
(e.g., ORIGINAL_BRANCH) and add a cleanup function that switches back to that
branch; register it with trap to run on EXIT/ERR so the script returns the user
to ORIGINAL_BRANCH on success or failure, and only attempt the switch-back if
ORIGINAL_BRANCH is not the same as CHERRY_PICK_BRANCH and is not "HEAD"
(detached); update the section around the git switch -c
"origin/${RELEASE_BRANCH}" to use this saved ORIGINAL_BRANCH and ensure the
trap/cleanup is installed immediately after capturing ORIGINAL_BRANCH.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/workflows/create-release-branch.yml.github/workflows/lint.ymlMakefilehack/cherry-pick.shpkg/cloudprovider/metal/suite_test.go
Summary by CodeRabbit
Release Notes