Skip to content

Conversation

@jackmisner
Copy link
Owner

@jackmisner jackmisner commented Jan 21, 2026

Summary by CodeRabbit

  • Chores
    • Version bumped to 0.1.1.
    • Added automated release commands for patch/minor/major to streamline publishing.
    • CI Node version updated to 24 to align build and publish environments.

✏️ Tip: You can customise this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Walkthrough

Adds release automation: new scripts/release.js, three npm release scripts in package.json, package version bumped to 0.1.1, and CI Node version updated from 22 to 24 in .github/workflows/publish.yml.

Changes

Cohort / File(s) Summary
Release scripts & package metadata
package.json, scripts/release.js
Bumped version from 0.1.0 to 0.1.1; added release:patch, release:minor, release:major npm scripts; introduced scripts/release.js implementing release flow: validate bump type, read current version, ensure on main, pull latest, check clean working tree, create release/<newVersion> branch, run npm version, push branch and tags, and print next steps.
CI Node version
.github/workflows/publish.yml
Updated Node.js runtime from 22 to 24 in workflow jobs.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant Dev as Developer
participant Script as Release Script
participant GitLocal as Local Git
participant Remote as Git Remote
participant NPM as NPM
Dev->>Script: run node scripts/release.js <patch|minor|major>
Script->>Script: validate bump type
Script->>NPM: read current version from package.json
Script->>GitLocal: check current branch
alt not on main
GitLocal-->>Script: non-main -> abort
else on main
Script->>GitLocal: git pull origin main
GitLocal-->>Script: latest main
Script->>GitLocal: check for uncommitted changes
alt uncommitted changes
GitLocal-->>Script: dirty -> abort
else clean
Script->>GitLocal: create branch release/<newVersion>
Script->>NPM: run npm version <type> (bump & tag)
NPM-->>Script: updated package.json & tag
Script->>Remote: push branch and tags (prefer origin)
Remote-->>Script: confirm push
Script->>Dev: print next steps and exit
end
end

🚥 Pre-merge checks | ✅ 1 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Release/0.1.1' is vague and generic, using a branch-naming pattern rather than describing the actual changes made (version bump, release automation scripts, and Node.js version update). Use a descriptive title that summarises the main changes, such as 'Add release automation scripts and bump version to 0.1.1' or 'Implement semantic versioning release automation'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

🤖 Fix all issues with AI agents
In `@scripts/release.js`:
- Around line 83-89: The script currently stages and commits all uncommitted
changes using runCapture('git status --porcelain') and run(...) which is risky;
change the behavior so that when status is non-empty (the variable status from
runCapture) the script aborts with a clear error instructing the user to
review/clean their working directory (rather than calling run('git add .') and
run(`git commit -m "chore: prepare for v${newVersion} release"`)). Update the
logic around status in the release flow to exit non-zero with a helpful message
referencing newVersion, and remove or disable the automatic run('git add
.')/run(...commit...) calls so commits are only done manually after the user
verifies changes.
🧹 Nitpick comments (3)
scripts/release.js (3)

25-38: Version parsing doesn't handle pre-release versions.

The split('.').map(Number) approach will produce NaN for versions containing pre-release identifiers (e.g., 1.0.0-beta.1). Whilst this may be acceptable for your current workflow, consider adding validation.

🔧 Optional: Add basic validation
 function calculateNewVersion(current, type) {
   const [major, minor, patch] = current.split('.').map(Number)
+  
+  if ([major, minor, patch].some(n => isNaN(n) || n < 0)) {
+    throw new Error(`Invalid version format: ${current}`)
+  }

   switch (type) {

103-112: Hardcoded repository URL reduces portability.

The PR URL is hardcoded to jackmisner/utm-toolkit. If this script is ever used in a fork or the repository is renamed, the link will be incorrect.

🔧 Dynamically derive the repository URL from the git remote
+function getRepoUrl(remote) {
+  const url = runCapture(`git remote get-url ${remote}`)
+  // Convert SSH to HTTPS format and remove .git suffix
+  return url
+    .replace(/^git@github\.com:/, 'https://github.com/')
+    .replace(/\.git$/, '')
+}
+
 function main() {
   // ... existing code ...
   const remote = getRemoteName()
+  const repoUrl = getRepoUrl(remote)
   // ... later in the success message ...

Then update the message:

-1. Create a PR: https://github.com/jackmisner/utm-toolkit/compare/main...${branchName}
+1. Create a PR: ${repoUrl}/compare/main...${branchName}

91-101: Consider rollback on failure.

If npm version or git push fails, the script leaves behind a partially created release branch. This isn't critical but could cause confusion for subsequent release attempts.

You could wrap these operations in a try-catch and delete the local branch on failure:

try {
  run(`git checkout -b ${branchName}`)
  run(`npm version ${type}`)
  run(`git push -u ${remote} ${branchName} --follow-tags`)
} catch (error) {
  console.error('❌ Release failed, cleaning up...')
  run('git checkout main')
  run(`git branch -D ${branchName}`)
  process.exit(1)
}

@jackmisner jackmisner merged commit 868f0a9 into main Jan 21, 2026
5 checks passed
@jackmisner jackmisner deleted the release/0.1.1 branch January 21, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants