fix(release): switch to master before creating version bump PR#466
Conversation
The release event checks out the tag (detached HEAD), which causes peter-evans/create-pull-request to fail with git exit code 128. Switch to master and re-apply the version bump before creating the PR. Also bumps package.json to 0.25.4 (missed by the failed workflow).
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds a workflow step that restores intermediate changes, checks out the repository default branch, and re-applies the npm version bump without creating a git tag; updates the create-pull-request action to v8 and targets the default branch; bumps package.json 0.25.3 → 0.25.4. Changes
Sequence Diagram(s)sequenceDiagram
participant WF as Workflow
participant Repo as Repository (checkout)
participant NPM as npm
participant PR as Create-Pull-Request Action
WF->>Repo: restore intermediate files
WF->>Repo: checkout default branch
WF->>NPM: run `npm version --no-git-tag-version`
NPM-->>Repo: updated package.json (no tag)
WF->>PR: open PR targeting default branch (chore/release-${version})
PR-->>Repo: creates PR with labels/body
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.github/workflows/release.yml (2)
78-81: Hard-codedmasterin a step named "Switch to default branch"
git checkout masterwill silently break if the default branch is ever renamed. The step's own name acknowledges the concept of "default branch" — use the context expression to match:♻️ Proposed fix
- - name: Switch to default branch for version bump - run: | - git checkout master - npm version "${{ steps.ver.outputs.version }}" --no-git-tag-version + - name: Switch to default branch for version bump + run: | + git checkout "${{ github.event.repository.default_branch }}" + npm version "${{ steps.ver.outputs.version }}" --no-git-tag-versionThe same applies to the unchanged
base: masteron line 86 — worth updating tobase: ${{ github.event.repository.default_branch }}in the same pass.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 78 - 81, In the "Switch to default branch for version bump" step replace the hard-coded git checkout master with checkout of the repository default branch using the GitHub context expression (use ${{ github.event.repository.default_branch }}), and in the later step that still uses base: master update that value to base: ${{ github.event.repository.default_branch }} so the workflow follows the repository's actual default branch; update the two locations (the step named "Switch to default branch for version bump" and the action input named base) accordingly.
83-96: Upgradepeter-evans/create-pull-request@v6to@v8— multiple breaking changes require attentionThe latest available version is
v8.1.0(current as of January 2026). Upgrading is recommended, but be aware of breaking changes introduced between v6 and v8:
- Input
git-tokenrenamed tobranch-token(v7) — update thewith:section if used- Environment variable
PULL_REQUEST_NUMBERremoved (v7) — use step outputpull-request-numberinstead- Output
pull-request-operationcan now benone(v7) — verify any conditional logic checking this value- Node.js runtime upgraded from 20 to 24 — self-hosted runners must use Actions Runner ≥ 2.327.1
Review the migration path to ensure none of these affect your workflow before upgrading.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 83 - 96, Update the action reference to peter-evans/create-pull-request@v8 and adjust inputs/consumers for breaking changes: if you pass a token input, rename input key git-token to branch-token in the with: block (the step named "Create PR for version bump back to default branch"); replace any references to the removed environment variable PULL_REQUEST_NUMBER with the step output pull-request-number (use the action's step ID) wherever consumed; update any conditional logic that checks the action output pull-request-operation to handle the new possible value "none"; and ensure self-hosted runners meet the Node/runner requirement (Actions Runner ≥ 2.327.1) because the action now runs on Node 24.
🤖 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/release.yml:
- Around line 78-81: In the "Switch to default branch for version bump" step
replace the hard-coded git checkout master with checkout of the repository
default branch using the GitHub context expression (use ${{
github.event.repository.default_branch }}), and in the later step that still
uses base: master update that value to base: ${{
github.event.repository.default_branch }} so the workflow follows the
repository's actual default branch; update the two locations (the step named
"Switch to default branch for version bump" and the action input named base)
accordingly.
- Around line 83-96: Update the action reference to
peter-evans/create-pull-request@v8 and adjust inputs/consumers for breaking
changes: if you pass a token input, rename input key git-token to branch-token
in the with: block (the step named "Create PR for version bump back to default
branch"); replace any references to the removed environment variable
PULL_REQUEST_NUMBER with the step output pull-request-number (use the action's
step ID) wherever consumed; update any conditional logic that checks the action
output pull-request-operation to handle the new possible value "none"; and
ensure self-hosted runners meet the Node/runner requirement (Actions Runner ≥
2.327.1) because the action now runs on Node 24.
…pull-request to v8
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release.yml:
- Line 80: The checkout step uses an unquoted Actions expression; assign the
expression to a named env var and use that quoted env var in the shell so the
branch name is passed as a single word to git; specifically set an environment
variable like DEFAULT_BRANCH to ${{ github.event.repository.default_branch }} in
the job/step env and replace the current git checkout ${{
github.event.repository.default_branch }} invocation with git checkout
"$DEFAULT_BRANCH" (refer to the checkout command and the new DEFAULT_BRANCH env
variable).
- Around line 78-81: Uncommitted package.json/package-lock.json changes from the
earlier npm version call will block git checkout; before switching branches in
the step that runs git checkout ${{ github.event.repository.default_branch }}
and npm version "${{ steps.ver.outputs.version }}", discard those intermediate
changes (e.g., run git restore package.json package-lock.json or git checkout --
package.json package-lock.json) so the checkout succeeds, and use an env var for
the default branch name instead of inline quoting to avoid quoting issues;
update the step around the git checkout/npm version commands (referencing the
git checkout and npm version "${{ steps.ver.outputs.version }}" lines) to run
the discard command first.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
That's a complex piece of stuff 🤯 I almost regret touching it 😅 But Coderabbit seems satisfied now 🙂 |
The 0.25.4 release was published to npm successfully, but the automated version bump PR was never created —
package.jsononmasterstill says0.25.3.This happened because the release workflow (which I refactored in PR #463) checks out the release tag, which results in a detached HEAD.
peter-evans/create-pull-requestthen fails with git exit code 128 because it cannot push a branch from a detached state.Failed run: https://github.com/jens-maus/node-ical/actions/runs/22280144048
Sorry for the oversight! This PR fixes it by explicitly switching to
masterafter the npm publish step and re-applyingnpm versionthere, socreate-pull-requesthas a proper branch to work from.Also includes the missing
package.jsonbump to0.25.4. No new release needed — the published npm package is correct, this just syncsmasterand prevents the issue from recurring.Summary by CodeRabbit