Skip to content

Conversation

@rajadilipkolli
Copy link
Collaborator

@rajadilipkolli rajadilipkolli commented Apr 5, 2023

Steps to be done before merging PR

Summary by CodeRabbit

  • Chores
    • Expanded continuous integration to test against Node.js 22.x (alongside 20.x), improving runtime compatibility coverage.
    • Introduced automated npm publishing triggered by semantic version tags, enabling faster, more reliable package releases.

@rajadilipkolli rajadilipkolli added this to the 0.1.3 milestone Apr 5, 2023
@rajadilipkolli rajadilipkolli linked an issue Apr 5, 2023 that may be closed by this pull request
@rajadilipkolli rajadilipkolli added the enhancement New feature or request label Apr 5, 2023
@sivaprasadreddy
Copy link
Owner

@rajadilipkolli Added NPM_USERNAME and NPM_AUTH_TOKEN secrets.

@rajadilipkolli rajadilipkolli modified the milestones: 0.1.3, 0.1.4 Jun 29, 2023
@rajadilipkolli rajadilipkolli modified the milestones: 0.1.4, 0.1.5 Oct 25, 2023
@rajadilipkolli rajadilipkolli modified the milestones: 0.1.5, 0.1.6 Nov 8, 2023
@rajadilipkolli
Copy link
Collaborator Author

Hi @sivaprasadreddy ,

can you please review and merge this PR.

- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for checking version changes
- name: Check for version change
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to create a separate release.yml GH Action configuration that gets triggered when tagged with *.*.* instead of programmatically checking if version is changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sivaprasadreddy,

Addressed the same. Can you please review and approve the same.

@coderabbitai
Copy link

coderabbitai bot commented Sep 20, 2025

Warning

Rate limit exceeded

@rajadilipkolli has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 350ca20 and 112fe97.

📒 Files selected for processing (1)
  • .github/workflows/release.yml (1 hunks)

Walkthrough

The build workflow matrix now tests Node.js 20.x and 22.x and fixes the matrix variable reference. A new release workflow publishes to npm on semantic version tag pushes, setting up Node 22.x, installing, testing, and publishing with NPM_TOKEN.

Changes

Cohort / File(s) Summary of Changes
CI Matrix Update
.github/workflows/build.yml
Updated Node.js matrix from 18.x/20.x to 20.x/22.x; corrected step variable from matrix.node-version to matrix.node_version and aligned with: node-version usage.
Release Publishing Workflow
.github/workflows/release.yml
Added workflow triggered by semver tag pushes; sets up Node 22.x, configures npm registry, runs npm ci and tests with CI=true, and publishes to npm using secrets.NPM_TOKEN.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant GH as GitHub
    participant WF as Release Workflow
    participant NPM as npm Registry

    Dev->>GH: Push tag (e.g., v1.2.3)
    GH-->>WF: Trigger on semver tag
    rect rgb(235, 245, 255)
    note right of WF: Job: release
    WF->>WF: actions/checkout@vX
    WF->>WF: setup-node (22.x) + npm registry
    WF->>WF: npm ci
    WF->>WF: CI=true npm test
    end
    alt Publish
        WF->>NPM: npm publish (auth: secrets.NPM_TOKEN)
        NPM-->>WF: 201 Created
    else Failure
        WF-->>GH: Job fails (logs)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws on versioned ground,
Tags hop by—v1, v2—what a sound!
With 22 we build and test,
Then ship to npm—hare’s behest.
Carrots cached, releases bright,
CI moonlit, green checks alight.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly states the primary change—automating publishing to npmjs—which aligns with the added release workflow and CI updates in the PR. It is concise, clear, and directly related to the main intent without extraneous details. A teammate scanning history would understand the primary change from the title alone.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (9)
.github/workflows/build.yml (3)

20-23: Add dependency caching to speed up CI.

Enable setup-node caching for npm installs.

 - name: Use Node.js ${{ matrix.node_version }}
 uses: actions/setup-node@v4
 with:
-  node-version: ${{ matrix.node_version }}
+  node-version: ${{ matrix.node_version }}
+  cache: 'npm'

25-27: Prefer npm ci in CI.

npm ci is faster and enforces lockfile consistency.

-      - run: npm install
+      - run: npm ci

2-6: Also trigger on pull requests.

Current workflow only runs on branch pushes; PRs from forks won’t be validated.

 on:
   push:
     branches:
       - '**'
+  pull_request:
+    branches:
+      - '**'
.github/workflows/release.yml (6)

9-11: Enable OIDC and publish with provenance (supply-chain hardening).

Add minimal job permissions to mint an identity token; then publish with --provenance.

 jobs:
   release:
     name: Publish to NPM
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      id-token: write

28-31: Attach provenance to the npm package.

This adds build attestation; npm supports --provenance when running in GitHub Actions.

-      - name: Publish to NPM
-        run: npm publish
+      - name: Publish to NPM
+        run: npm publish --provenance
         env:
           NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Note: keep the chosen secret name in sync with the previous comment.


20-22: Guard against missing lockfile.

npm ci fails if package-lock.json is absent. Optional fallback:

-      - name: Install dependencies
-        run: npm ci
+      - name: Install dependencies
+        run: |
+          if [ -f package-lock.json ]; then npm ci; else npm install --no-audit --no-fund; fi

28-31: Public access for scoped packages (if applicable).

If the package name in package.json is scoped (starts with @), add --access public or publish will be restricted.

-        run: npm publish --provenance
+        run: npm publish --provenance --access public

If the package is unscoped (e.g., generator-springboot), ignore this.


31-31: Add trailing newline.

YAMLlint flagged missing newline at EOF.


14-19: Token type recommendation.

Use an npm “Automation” token with publish-only scope for least privilege. Classic tokens are broader.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 580398a and 350ca20.

📒 Files selected for processing (2)
  • .github/workflows/build.yml (2 hunks)
  • .github/workflows/release.yml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/release.yml

[error] 31-31: no new line character at the end of file

(new-line-at-end-of-file)

⏰ 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: npm test (22.x, windows-latest)
🔇 Additional comments (3)
.github/workflows/build.yml (1)

15-16: Matrix update to Node 22.x/20.x looks good.

Keeps CI current while retaining LTS coverage.

.github/workflows/release.yml (2)

1-31: Verify tag/version alignment before publishing.

Fail the workflow if the pushed tag (with or without leading "v") doesn't match package.json version — add this as a step before "Publish to NPM" in .github/workflows/release.yml.

#!/usr/bin/env bash
set -euo pipefail

PKG_VERSION=$(jq -r '.version' package.json)

# Use first arg, then GITHUB_REF_NAME, then GITHUB_REF (safe defaults to avoid unbound-var)
TAG_REF="${1:-${GITHUB_REF_NAME:-${GITHUB_REF:-}}}"
TAG_REF="${TAG_REF##refs/tags/}"
TAG_VERSION="${TAG_REF#v}"

if [ -z "$TAG_VERSION" ]; then
  echo "No tag detected (provide tag as arg or run in CI where GITHUB_REF/GITHUB_REF_NAME is set)." >&2
  exit 1
fi

if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
  echo "Version mismatch: package.json=$PKG_VERSION, tag=$TAG_REF" >&2
  exit 1
fi

echo "Version OK: $PKG_VERSION"

Integrate as a workflow step named e.g. "Verify tag matches package.json" immediately before the "Publish to NPM" step.


5-5: Tag filter is using regex-like syntax; it won’t match as intended.

GitHub uses glob patterns, not regex. + has no meaning here and will make the workflow fail to trigger.

Use glob patterns that cover common semver tags:

-      - '[0-9]+.[0-9]+.[0-9]+' # Matches semantic version tags like 1.2.3
+      - '*.*.*'          # e.g., 1.2.3
+      - 'v*.*.*'         # e.g., v1.2.3
+      - '*.*.*-*'        # e.g., 1.2.3-rc.1 (optional)
+      - 'v*.*.*-*'       # e.g., v1.2.3-beta.0 (optional)

Likely an incorrect or invalid review comment.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automate npm release process

3 participants