feat: adopt changesets for automated versioning and publishing#6
feat: adopt changesets for automated versioning and publishing#6
Conversation
Replace the manual version bump + GitHub release trigger workflow with changesets, so version bumps and npm publishing are handled automatically via a "Version Packages" PR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
The PR successfully implements the Changeset infrastructure for automated versioning and publishing. While the project is 'Up to Standards' according to Codacy, two major issues must be addressed before merging:
- CI Failure: This PR introduces a mandatory changeset check but does not include a changeset for its own changes, which will lead to a failed CI status.
- Release Reliability: The release workflow triggers concurrently with the CI workflow on pushes to the main branch. Without a test step in the release workflow, there is a risk of publishing broken packages if the release completes before a failing CI job finishes.
About this PR
- The 'release' script in package.json depends on a prior build step (npm run build). While the release.yml workflow handles this correctly, developers attempting to run 'npm run release' locally may experience failures if they have not manually executed the build first.
Test suggestions
- Verify 'changeset-check' CI job fails when no changeset file is added to a PR.
- Verify 'changeset-check' CI job passes when a new .changeset/*.md file (excluding README) is present.
- Verify 'release.yml' triggers on push to main and correctly uses secrets.NPM_TOKEN for publishing.
- Verify 'release' script in package.json correctly invokes the changeset CLI publish command.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Create Release PR or Publish |
There was a problem hiding this comment.
🔴 HIGH RISK
The release workflow currently publishes the package without running tests. Since ci.yml and release.yml run concurrently on pushes to main, a failing build on main could still result in a successful (but broken) package publication. Add a test step before the release action. Try running the following prompt in your coding agent: > Add a 'Test' step running 'npm test' before the 'Create Release PR or Publish' step in .github/workflows/release.yml.
There was a problem hiding this comment.
Good catch — adding a test step before publish in release.yml, and setting NPM_CONFIG_PROVENANCE=true to preserve provenance signing.
🤖 Generated by /pr-fixup command
| - name: Check for changesets | ||
| run: | | ||
| # Count .changeset/*.md files added/modified in this PR compared to the base branch | ||
| CHANGESETS=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '.changeset/*.md' ':!.changeset/README.md' | wc -l) |
There was a problem hiding this comment.
🟡 MEDIUM RISK
This PR is missing a changeset file. Based on the logic added in this line, the CI job will fail because no file matching '.changeset/*.md' (excluding README.md) was found in the diff. Please add a changeset using 'npx changeset' or 'npx changeset --empty'.
There was a problem hiding this comment.
Already addressed — an empty changeset was added in the second commit (fresh-spoons-build.md). The changeset-check job is now passing.
🤖 Generated by /pr-fixup command
| "test": "vitest run", | ||
| "build": "tsc -p tsconfig.build.json && chmod +x dist/index.js", | ||
| "prepublishOnly": "npm run update-api && npm run build", | ||
| "changeset": "changeset", |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Removing the prepublishOnly hook eliminates a critical safety check. This script ensures that the API client is generated and the project is built whenever a publish is attempted, protecting against manual errors or local publishes of stale code.
| "changeset": "changeset", | |
| "prepublishOnly": "npm run update-api && npm run build", | |
| "changeset": "changeset", |
There was a problem hiding this comment.
Good point — restoring prepublishOnly as a safety net for any accidental local publish attempts.
🤖 Generated by /pr-fixup command
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s release/publish process from a manual GitHub Release → npm publish flow to a Changesets-driven workflow, aligning automated versioning + changelog generation + npm publishing with the process used elsewhere.
Changes:
- Add Changesets tooling/config and scripts to support automated versioning and publishing.
- Introduce a new
release.ymlworkflow usingchangesets/actionand remove the legacypublish.ymlworkflow. - Add a CI job that enforces presence of a changeset file on pull requests.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds Changesets scripts and devDependencies for versioning/publishing. |
| package-lock.json | Locks new Changesets-related dependencies. |
| .github/workflows/release.yml | New automated release workflow to create version PRs and publish to npm. |
| .github/workflows/publish.yml | Removes the old release-triggered npm publish workflow. |
| .github/workflows/ci.yml | Adds PR enforcement job requiring a changeset. |
| .changeset/README.md | Adds Changesets-generated README for contributors. |
| .changeset/config.json | Adds Changesets configuration (changelog, base branch, access). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "scripts": { | ||
| "test": "vitest run", | ||
| "build": "tsc -p tsconfig.build.json && chmod +x dist/index.js", | ||
| "prepublishOnly": "npm run update-api && npm run build", | ||
| "changeset": "changeset", | ||
| "version-packages": "changeset version", | ||
| "release": "changeset publish", | ||
| "start": "npx ts-node src/index.ts", |
There was a problem hiding this comment.
Agreed — restoring prepublishOnly as a safety net. The release.yml workflow handles the full build pipeline, but prepublishOnly guards against stale local publishes.
🤖 Generated by /pr-fixup command
| - name: Check for changesets | ||
| run: | | ||
| # Count .changeset/*.md files added/modified in this PR compared to the base branch | ||
| CHANGESETS=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- '.changeset/*.md' ':!.changeset/README.md' | wc -l) | ||
| if [ "$CHANGESETS" -eq 0 ]; then | ||
| echo "::error::No changeset found for this PR. Run 'npx changeset' to describe your changes." | ||
| echo "" | ||
| echo "If this PR does not require a version bump (e.g., docs-only or CI changes)," | ||
| echo "add an empty changeset with: npx changeset --empty" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Already addressed — an empty changeset was added in the second commit. The changeset-check CI job is passing.
🤖 Generated by /pr-fixup command
| - name: Generate API client | ||
| run: npm run update-api | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| - name: Create Release PR or Publish | ||
| uses: changesets/action@6a0a831ff30acef54f2c6aa1cbbc1096b066edaf # v1 | ||
| with: | ||
| publish: npm run release |
There was a problem hiding this comment.
Good catch — adding a test step before the changesets action in release.yml.
🤖 Generated by /pr-fixup command
| commit: "chore: version packages" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
There was a problem hiding this comment.
Good catch — adding NPM_CONFIG_PROVENANCE=true to the changesets action env to preserve provenance signing.
🤖 Generated by /pr-fixup command
| @@ -0,0 +1,14 @@ | |||
| { | |||
| "$schema": "https://unpkg.com/@changesets/config@3.1.3/schema.json", | |||
- Add test step to release.yml before publishing (Codacy + Copilot review) - Restore prepublishOnly as safety net for local publishes (Codacy + Copilot review) - Set NPM_CONFIG_PROVENANCE=true to preserve provenance signing (Copilot review) - Update README CI/CD section with new changesets workflow - Add versioning/changesets section to AGENTS.md with agent responsibilities - Add agent self-documentation guidelines to AGENTS.md - Update SPECS/deployment.md to reflect new release workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
analysis-clirelease.ymlworkflow that useschangesets/actionto automatically create a "Version Packages" PR (bumps version, updates CHANGELOG) and publishes to npm when that PR is mergedchangeset-checkCI job that requires every PR to include a changeset file (or an explicit--emptychangeset for non-version-bump changes)publish.ymlworkflow that required manually creating a GitHub release with a matchingpackage.jsonversionNew workflow
npx changesetto describe the change and select bump type (patch/minor/major).changeset/*.mdfile in the PRmain, the release workflow creates/updates a "Version Packages" PRTest plan
npx changesetworks and the changeset-check job enforces it🤖 Generated with Claude Code