feat(desktop): add --merge flag to release script#884
Conversation
Add optional --merge flag that merges the release PR and deletes the branch after publishing. This allows for a fully automated release workflow when used with --publish --merge.
📝 WalkthroughWalkthroughThe desktop release flow adds an optional Changes
Sequence Diagram(s)sequenceDiagram
participant Script as "create-release.sh"
participant GHCLI as "gh (GitHub CLI)"
participant GitHub as "GitHub API / Repo"
Script->>GHCLI: check for existing PR / create PR
GHCLI->>GitHub: list/create PR (returns PR URL)
GitHub-->>GHCLI: PR URL (contains PR_NUMBER)
GHCLI-->>Script: PR_NUMBER
Script->>GHCLI: publish release (gh release create with notes)
GHCLI->>GitHub: create draft release
GitHub-->>GHCLI: release created
alt AUTO_MERGE true and PR_NUMBER present
Script->>GHCLI: squash-merge PR (gh pr merge --squash --delete-branch)
GHCLI->>GitHub: merge PR and delete branch
GitHub-->>GHCLI: merge result
GHCLI-->>Script: merge success/failure
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/desktop/create-release.sh (1)
86-110: Prevent--mergefrom silently no-op’ing without--publish.Right now
--mergecan be passed alone and nothing happens, which is surprising. Consider a hard validation so users learn the dependency early.🔧 Suggested guard
for arg in "$@"; do @@ esac done + +if [ "$AUTO_MERGE" = true ] && [ "$AUTO_PUBLISH" != true ]; then + error "--merge requires --publish (merge occurs only after publishing)." +fi
🧹 Nitpick comments (2)
apps/desktop/create-release.sh (2)
283-305: Avoid parsing PR numbers from free‑form output.
grep -oE '[0-9]+$'is brittle ifgh pr createemits additional lines or warnings. Consider querying the PR number viagh pr viewor reusinggh pr list --headafter creation for a deterministic result.♻️ More robust PR number retrieval
if [ $? -eq 0 ]; then success "Pull request created: ${PR_URL}" - # Extract PR number from URL - PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$') + # Resolve PR number from GitHub rather than parsing output + PR_NUMBER=$(gh pr view "$PR_URL" --json number --jq .number 2>/dev/null || echo "") else warn "Could not create PR: ${PR_URL}" fi
409-417: Consider warning when merge is requested but no PR is available.If
--mergeis set butPR_NUMBERis empty (e.g., onmainor PR creation failed), the script silently skips merging. A short warning would reduce confusion.🔔 Optional UX improvement
- if [ "$AUTO_MERGE" = true ] && [ -n "$PR_NUMBER" ]; then + if [ "$AUTO_MERGE" = true ] && [ -n "$PR_NUMBER" ]; then info "Merging PR #${PR_NUMBER}..." if gh pr merge "${PR_NUMBER}" --squash --delete-branch; then success "PR #${PR_NUMBER} merged and branch deleted" else warn "Could not merge PR #${PR_NUMBER}. You may need to merge it manually." fi + elif [ "$AUTO_MERGE" = true ]; then + warn "Auto-merge requested, but no PR number was detected." fi
Find the previous desktop release tag (e.g., desktop-v0.0.58 for desktop-v0.0.59) when generating release notes, so the "What's Changed" section only includes changes since the last desktop release. Uses GitHub API to generate release notes with the correct previous tag comparison instead of comparing against the most recent tag of any type.
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
Summary
--mergeflag to the release script that merges the release PR and deletes the branch after publishingdesktop-v0.0.58→desktop-v0.0.59) so "What's Changed" only shows desktop-related changesUsage
Test plan
Summary by CodeRabbit
New Features
--mergecommand-line option to automatically merge pull requests after release publication.Chores
✏️ Tip: You can customize this high-level summary in your review settings.