Skip to content

feat: adopt changesets for automated versioning and publishing#6

Merged
alerizzo merged 3 commits intomainfrom
feat/changesets-release-flow
May 8, 2026
Merged

feat: adopt changesets for automated versioning and publishing#6
alerizzo merged 3 commits intomainfrom
feat/changesets-release-flow

Conversation

@alerizzo
Copy link
Copy Markdown
Collaborator

@alerizzo alerizzo commented May 8, 2026

Summary

  • Replaces the manual GitHub release → npm publish workflow with changesets, matching the flow used in analysis-cli
  • Adds a release.yml workflow that uses changesets/action to automatically create a "Version Packages" PR (bumps version, updates CHANGELOG) and publishes to npm when that PR is merged
  • Adds a changeset-check CI job that requires every PR to include a changeset file (or an explicit --empty changeset for non-version-bump changes)
  • Removes the old publish.yml workflow that required manually creating a GitHub release with a matching package.json version

New workflow

  1. Make changes, run npx changeset to describe the change and select bump type (patch/minor/major)
  2. Include the generated .changeset/*.md file in the PR
  3. On merge to main, the release workflow creates/updates a "Version Packages" PR
  4. Merging that PR bumps the version, updates CHANGELOG.md, and publishes to npm

Test plan

  • Verify CI passes on this PR (changeset-check job should pass since this is a CI-only change — add an empty changeset if needed)
  • After merge, verify the release workflow creates a "Version Packages" PR
  • On a follow-up PR, verify npx changeset works and the changeset-check job enforces it

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 8, 2026 13:45
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 8, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

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

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:

  1. 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.
  2. 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Comment thread .github/workflows/ci.yml
- 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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'.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Comment thread package.json
"test": "vitest run",
"build": "tsc -p tsconfig.build.json && chmod +x dist/index.js",
"prepublishOnly": "npm run update-api && npm run build",
"changeset": "changeset",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.

Suggested change
"changeset": "changeset",
"prepublishOnly": "npm run update-api && npm run build",
"changeset": "changeset",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.yml workflow using changesets/action and remove the legacy publish.yml workflow.
  • 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.

Comment thread package.json
Comment on lines 20 to 26
"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",
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Comment thread .github/workflows/ci.yml
Comment on lines +50 to +60
- 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
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Already addressed — an empty changeset was added in the second commit. The changeset-check CI job is passing.

🤖 Generated by /pr-fixup command

Comment on lines +32 to +41
- 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
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 }}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — adding NPM_CONFIG_PROVENANCE=true to the changesets action env to preserve provenance signing.

🤖 Generated by /pr-fixup command

Comment thread .changeset/config.json
@@ -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>
@alerizzo alerizzo merged commit 0280af1 into main May 8, 2026
5 checks passed
@alerizzo alerizzo deleted the feat/changesets-release-flow branch May 8, 2026 17:19
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