ci: update changesets auto-merge logic#9703
Conversation
|
WalkthroughThe release workflow in .github/workflows/release.yml is refactored to use the Changesets GitHub Action for versioning and publishing, removes manual git commit/push steps, adds PR-based auto-merge logic, introduces NPM_TOKEN usage, exposes PR/REPO inputs for downstream steps, and preserves Codecov upload with updated context. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant GH as GitHub Actions: release.yml
participant CS as Changesets Action
participant GHPR as Pull Requests
participant NPM as npm Registry
participant CV as Codecov
Dev->>GH: Push changes / trigger workflow
GH->>CS: Run Changesets (version or publish)
alt Version required
CS->>GHPR: Create/Update "Version Packages" PR
GH->>GHPR: Auto-merge PR (squash) when ready
GH->>CS: Re-run to publish (post-merge)
else No version changes
CS-->>GH: No-op for version
end
CS->>NPM: Publish packages (uses NPM_TOKEN)
GH->>CV: Upload coverage (PR-aware context)
note over GH,NPM: PR-based merge/publish replaces local git commit/push
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Comment |
|
View your CI Pipeline Execution ↗ for commit 64facb8
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/release.yml(1 hunks)packages/query-core/src/index.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Test
| - name: Auto-merge Changesets PR | ||
| if: steps.changesets.outputs.hasChangesets | ||
| run: gh pr --repo "$REPO" merge --auto --squash "$PR_NUM" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Publish Packages | ||
| run: | | ||
| npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" | ||
| pnpm run changeset:publish | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| PR_NUM: ${{ steps.changesets.outputs.pullRequestNumber }} | ||
| REPO: ${{ github.repository }} |
There was a problem hiding this comment.
Guard the auto-merge step correctly.
steps.changesets.outputs.hasChangesets is a string ('true'/'false'). Without an explicit comparison, the step still runs when the value is 'false', leaving PR_NUM empty and making gh pr merge fail, which will break every release run without pending changesets. Compare the output to 'true' so we only invoke the CLI when a release PR actually exists.
- - name: Auto-merge Changesets PR
- if: steps.changesets.outputs.hasChangesets
+ - name: Auto-merge Changesets PR
+ if: steps.changesets.outputs.hasChangesets == 'true'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Auto-merge Changesets PR | |
| if: steps.changesets.outputs.hasChangesets | |
| run: gh pr --repo "$REPO" merge --auto --squash "$PR_NUM" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish Packages | |
| run: | | |
| npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" | |
| pnpm run changeset:publish | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| PR_NUM: ${{ steps.changesets.outputs.pullRequestNumber }} | |
| REPO: ${{ github.repository }} | |
| - name: Auto-merge Changesets PR | |
| if: steps.changesets.outputs.hasChangesets == 'true' | |
| run: gh pr --repo "$REPO" merge --auto --squash "$PR_NUM" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_NUM: ${{ steps.changesets.outputs.pullRequestNumber }} | |
| REPO: ${{ github.repository }} |
🤖 Prompt for AI Agents
.github/workflows/release.yml lines 48-54: the step uses if:
steps.changesets.outputs.hasChangesets which is a string and can be 'false' but
still considered truthy by Actions; change the if to explicitly compare the
output to the string 'true' (e.g., if: steps.changesets.outputs.hasChangesets ==
'true') so the auto-merge runs only when a release PR exists and PR_NUM is set.
|
Sizes for commit 64facb8:
|
* ci: update changesets auto-merge logic * Intentionally breaking build * Undo intentional break * Remove auto since we don't have auto-merge
🎯 Changes
Switches to the official
changesets/action, but usesgh pr mergeto auto-merge its release PR.Solution taken from changesets/action#310 (comment)
✅ Checklist
pnpm test:pr.🚀 Release Impact
Summary by CodeRabbit