Releases
This template uses Changesets for versioning and publishing.
Overview
Changesets is a versioning workflow that:
- Decouples changes from releases — Each PR adds a "changeset" describing what changed
- Accumulates changes — Multiple changesets combine into a single release
- Automates versioning — Determines the correct semver bump automatically
- Generates changelogs — Creates
CHANGELOG.mdfrom changeset descriptions
Workflow
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Make code │───▶│ Add │───▶│ Merge PR │───▶│ Merge │
│ changes │ │ changeset │ │ to main │ │ Version PR │
└─────────────┘ └─────────────┘ └─────────────┘ └──────┬──────┘
│
▼
┌─────────────┐
│ Auto-publish│
│ to npm │
└─────────────┘Adding a Changeset
When you make a change that should be released:
pnpm changesetThis interactive command asks:
- Which packages changed? — Select from the list (usually just the root package)
- Semver bump type? — patch, minor, or major
- Summary? — A brief description for the changelog
Choosing the Bump Type
| Bump | When to Use | Example |
|---|---|---|
| patch | Bug fixes, docs, internal changes | 1.0.0 → 1.0.1 |
| minor | New features (backward compatible) | 1.0.0 → 1.1.0 |
| major | Breaking changes | 1.0.0 → 2.0.0 |
Writing Good Summaries
Changeset summaries become your changelog. Write them for users:
Good:
Add `formatDate()` utility function for consistent date formattingBad:
fixed stuffGenerated File
The command creates a file like .changeset/fuzzy-tigers-dance.md:
---
"your-package-name": minor
---
Add `formatDate()` utility function for consistent date formattingCommit this file with your PR.
The Version PR
When changesets exist on main, the release workflow creates a Version Packages PR:
- Title:
chore: version packages - Changes:
- Bumps version in
package.json - Updates
CHANGELOG.md - Deletes consumed changesets
- Bumps version in
This PR stays open and updates automatically as new changesets merge.
Reviewing the Version PR
Before merging:
- Check the version bump is correct
- Review the changelog looks good
- Ensure CI passes
Publishing
When you merge the Version PR:
- Release workflow detects no pending changesets
- Runs quality gates (lint, test, build)
- Publishes to npm
- Creates a GitHub release with changelog
NPM Token Setup
The release workflow needs an npm token to publish.
Creating a Token
Go to npmjs.com → Account Settings → Access Tokens
Click Generate New Token → Granular Access Token
Configure:
- Name:
github-actions(or similar) - Expiration: Choose based on your security needs
- Packages: Select your package or "All packages"
- Permissions: Read and write
- Name:
Copy the token (shown only once)
Adding to GitHub
- Go to your GitHub repository → Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
NPM_TOKEN - Value: Paste your npm token
- Click Add secret
Manual Releases
If you need to release without the automated workflow:
# 1. Consume changesets and update versions
pnpm changeset version
# 2. Review changes
git diff
# 3. Commit
git add .
git commit -m "chore: version packages"
# 4. Publish
pnpm publish --access public
# 5. Push
git push
git push --tagsPrerelease Versions
For alpha/beta releases:
Enter Prerelease Mode
pnpm changeset pre enter alphaThis creates .changeset/pre.json. Now:
pnpm changeset versioncreates versions like1.0.0-alpha.0- Each version command increments the prerelease number
Exit Prerelease Mode
pnpm changeset pre exitThe next version will be a stable release.
Skip Changeset for a PR
Some changes don't need releases:
- Documentation-only changes
- CI/workflow changes
- Internal refactors with no external impact
For these, add an empty changeset:
pnpm changeset add --emptyThis satisfies CI checks without triggering a version bump.
Alternatively, if your repo has a CI check for changesets, you can skip it with:
[skip changeset]in your PR title or description (if configured).
Changeset Configuration
The config lives in .changeset/config.json:
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}| Option | Description |
|---|---|
changelog | Changelog format generator |
commit | Auto-commit version changes |
access | npm publish access (public or restricted) |
baseBranch | The main branch name |
updateInternalDependencies | How to bump internal workspace deps |
Troubleshooting
"No changesets found"
Cause: PR doesn't include a changeset file
Fix: Run pnpm changeset and commit the generated file
Version PR Not Updating
Cause: Release workflow may have failed
Check: Go to Actions tab and look for errors
Publish Failed
Common causes:
NPM_TOKENsecret not set or expired- Package name already taken on npm
- Version already published (can't overwrite)
Check: Release workflow logs for the specific error
Wrong Version Bump
Cause: Incorrect bump type selected when creating changeset
Fix: Edit the changeset file directly:
---
"your-package-name": patch <!-- Change this -->
---
Your descriptionBest Practices
- One changeset per PR — Easier to track
- Write for users — Changelog summaries are public
- Group related changes — Multiple commits can share one changeset
- Review Version PRs — Don't auto-merge without checking
- Use conventional commits — Even though changesets don't require them