Repository navigation
[CI] Add Release gh action - #181
Conversation
- updates semver from package.json - writes simple git oneline changelog for release notes - set default to updating minor, instead of patch as we've been doing
📝 WalkthroughWalkthroughA new GitHub Actions workflow has been added that automates the release process. It bumps the npm package version, generates release notes from git history, creates git tags, publishes to GitHub Releases, and packages the VS Code extension artifact. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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.
Actionable comments posted: 2
🧹 Nitpick comments (3)
.github/workflows/release.yml (3)
16-21: Serialize release runs.This workflow mutates shared repo state. Without a
concurrencygroup, two manual dispatches can race and both try to cut the same next version/tag.🧭 Suggested concurrency guard
permissions: contents: write +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + jobs:🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 16 - 21, The release job can race when multiple manual dispatches run; add a concurrency guard under the release job to serialize runs. Update the jobs.release configuration to include a concurrency block with a fixed group name (e.g., "release") and set cancel-in-progress: false so only one release runs at a time and subsequent runs wait; target the concurrency block for the existing "release" job to prevent simultaneous tag/version mutations.
55-56: Remove the extra lockfile step.
npm versionalready writes the new version topackage.jsonandpackage-lock.json. Runningnpm install --package-lock-onlyagain adds a second lockfile-generation path for no functional gain and opens the door to unnecessary lockfile churn. (docs.npmjs.com)♻️ Proposed simplification
- - name: Update package-lock.json - run: npm install --package-lock-only🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 55 - 56, Remove the redundant GitHub Actions step that runs "npm install --package-lock-only" (the step named "Update package-lock.json"); since "npm version" already updates package-lock.json, delete the step invoking npm install --package-lock-only to avoid duplicate lockfile generation and churn.
24-32: Pin Actions to immutable SHAs.
actions/checkout@v6andactions/setup-node@v6are movable tags. GitHub documents full commit SHAs as the only immutable reference and notes that repo/org policies can require SHA-pinned Actions, so this can drift or get blocked later. (docs.github.com)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/release.yml around lines 24 - 32, The workflow uses movable tags for third-party actions (the steps named "Checkout" and "Setup Node.js" referencing actions/checkout@v6 and actions/setup-node@v6); replace those version tags with the corresponding immutable commit SHAs for each action (obtain the full commit SHA from the action's GitHub repository or the Marketplace and use e.g. actions/checkout@<full-sha> and actions/setup-node@<full-sha>) so the workflow is pinned to an immutable reference and cannot drift or be blocked by org policies.
🤖 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:
- Around line 77-86: The workflow currently commits/tags/pushes in the "Commit
and tag" step before running the "Build .vsix" step which triggers the
package.json "vscode:prepublish" hook (npm run package); reorder the steps so
the packaging (npx `@vscode/vsce` package) runs and succeeds before creating the
git commit/tag/push, and ensure the commit/tag step only runs if the build step
succeeded (fail the job on build errors) so a version/tag is never pushed
without a successful .vsix build.
- Around line 3-14: The workflow currently allows manual triggers from any
branch; add a branch guard so mutating actions only run on main by checking the
ref. In the .github/workflows/release.yml workflow_dispatch setup keep as-is but
add an if condition on the job or the specific mutating steps (the steps that
perform commit/tag/push — the "Commit version", "Create tag", "Push changes"
steps referenced in the diff) such as if: github.ref == 'refs/heads/main' (or at
job level: if: github.ref == 'refs/heads/main') so these steps are skipped
unless the run is on main; ensure the same guard covers tagging and pushing
steps to prevent accidental releases from feature branches.
---
Nitpick comments:
In @.github/workflows/release.yml:
- Around line 16-21: The release job can race when multiple manual dispatches
run; add a concurrency guard under the release job to serialize runs. Update the
jobs.release configuration to include a concurrency block with a fixed group
name (e.g., "release") and set cancel-in-progress: false so only one release
runs at a time and subsequent runs wait; target the concurrency block for the
existing "release" job to prevent simultaneous tag/version mutations.
- Around line 55-56: Remove the redundant GitHub Actions step that runs "npm
install --package-lock-only" (the step named "Update package-lock.json"); since
"npm version" already updates package-lock.json, delete the step invoking npm
install --package-lock-only to avoid duplicate lockfile generation and churn.
- Around line 24-32: The workflow uses movable tags for third-party actions (the
steps named "Checkout" and "Setup Node.js" referencing actions/checkout@v6 and
actions/setup-node@v6); replace those version tags with the corresponding
immutable commit SHAs for each action (obtain the full commit SHA from the
action's GitHub repository or the Marketplace and use e.g.
actions/checkout@<full-sha> and actions/setup-node@<full-sha>) so the workflow
is pinned to an immutable reference and cannot drift or be blocked by org
policies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: db37a650-1044-44f1-af04-568408f8e8c3
📒 Files selected for processing (1)
.github/workflows/release.yml
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| bump: | ||
| description: "Version bump type" | ||
| required: true | ||
| default: "minor" | ||
| type: choice | ||
| options: | ||
| - patch | ||
| - minor | ||
| - major |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n .github/workflows/release.ymlRepository: Avni2000/MergeNB
Length of output: 3363
Restrict manual releases to the main branch.
The workflow_dispatch trigger has no branch restriction, allowing any branch to be released. Since the workflow commits, tags, and pushes (lines 77–83) before building and creating a release, an operator can inadvertently bump the version and publish from a feature branch. Add a guard to enforce main before any mutating step.
🔒 Proposed guard
jobs:
release:
runs-on: ubuntu-latest
steps:
+ - name: Enforce release branch
+ run: |
+ test "${GITHUB_REF}" = "refs/heads/main" || {
+ echo "Releases must run from main, got ${GITHUB_REF}" >&2
+ exit 1
+ }
+
- name: Checkout🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/release.yml around lines 3 - 14, The workflow currently
allows manual triggers from any branch; add a branch guard so mutating actions
only run on main by checking the ref. In the .github/workflows/release.yml
workflow_dispatch setup keep as-is but add an if condition on the job or the
specific mutating steps (the steps that perform commit/tag/push — the "Commit
version", "Create tag", "Push changes" steps referenced in the diff) such as if:
github.ref == 'refs/heads/main' (or at job level: if: github.ref ==
'refs/heads/main') so these steps are skipped unless the run is on main; ensure
the same guard covers tagging and pushing steps to prevent accidental releases
from feature branches.
| - name: Commit and tag | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.version }}" | ||
| git add package.json package-lock.json | ||
| git commit -m "Release v${VERSION}" | ||
| git tag "${VERSION}" | ||
| git push origin HEAD --follow-tags | ||
|
|
||
| - name: Build .vsix | ||
| run: npx @vscode/vsce package |
There was a problem hiding this comment.
Build the VSIX before pushing the tag.
Line 86 isn't just packaging: package.json:128-135 wires vscode:prepublish to npm run package, so lint, type-checking, and the production esbuild run happen after Lines 77-83 have already pushed the release commit and tag. If that build fails, the repo is left half-released with a new version/tag but no .vsix or GitHub Release.
🔁 Safer ordering
- - name: Commit and tag
- run: |
- VERSION="${{ steps.version.outputs.version }}"
- git add package.json package-lock.json
- git commit -m "Release v${VERSION}"
- git tag "${VERSION}"
- git push origin HEAD --follow-tags
-
- name: Build .vsix
run: npx `@vscode/vsce` package
+
+ - name: Commit and tag
+ run: |
+ VERSION="${{ steps.version.outputs.version }}"
+ git add package.json package-lock.json
+ git commit -m "Release v${VERSION}"
+ git tag "${VERSION}"
+ git push origin HEAD --follow-tags🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/release.yml around lines 77 - 86, The workflow currently
commits/tags/pushes in the "Commit and tag" step before running the "Build
.vsix" step which triggers the package.json "vscode:prepublish" hook (npm run
package); reorder the steps so the packaging (npx `@vscode/vsce` package) runs and
succeeds before creating the git commit/tag/push, and ensure the commit/tag step
only runs if the build step succeeded (fail the job on build errors) so a
version/tag is never pushed without a successful .vsix build.
There was a problem hiding this comment.
What difference does it make? The VSIX isn't committed
There was a problem hiding this comment.
@Avni2000 — The VSIX not being committed is exactly the point. Here's what happens when the build step fails under the current ordering:
- ✅
package.json/package-lock.jsonversion bump is already committed and pushed toorigin - ✅ The git tag (e.g.
1.2.0) is already pushed toorigin - ❌
npx@vscode/vscepackagefails (e.g. a type error, lint failure, or thevscode:prepublishesbuild step errors out) - ❌ The GitHub Release is never created — no artifact, no release page
The repo now has a dangling tag and a version-bump commit with no corresponding release. Cleaning that up requires manual steps:
git push origin --delete 1.2.0 # delete remote tag
git tag -d 1.2.0 # delete local tag
git revert HEAD # or reset the version bump commit
git push ...If instead the build runs before the push and it fails, the job simply errors out with zero side effects — no tag, no commit pushed, nothing to clean up. The fix is trivially re-running the workflow after addressing the build error.
In short: the ordering matters not because the VSIX is committed, but because the tag and version bump commit are irreversible once pushed, and they'd exist in the repo without a release to back them up.
Summary by CodeRabbit