changesets/action
Automate versioning and npm publishing for repos that use Changesets.
What it does
changesets/action reads pending changeset files and keeps a "Version Packages" pull request up to date with version bumps and changelogs. When that PR merges, it runs your publish script to release to npm.
It is the standard release automation for pnpm/npm monorepos using @changesets/cli.
Usage
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
- uses: changesets/action@v1
with:
publish-script: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}Inputs
| Input | Description | Default | Required |
|---|---|---|---|
github-token | The GitHub token to use for authentication. | ${{ github.token }} | No |
publish-script | The command to use to build and publish packages. | - | No |
version-script | The command to update version, edit CHANGELOG, read and delete changesets. Defaults to changeset version. | - | No |
commit-message | The commit message for the version commit. | Version Packages | No |
pr-title | The pull request title. | Version Packages | No |
create-github-releases | Whether to create GitHub releases after publish. | true | No |
commit-mode | How changes are pushed: "git-cli" or "github-api" (signed commits attributed to the token owner). | git-cli | No |
Outputs
| Output | Description |
|---|---|
published | Boolean indicating whether a publish happened. |
published-packages | JSON array of published packages with name and version. |
has-changesets | Boolean indicating whether there were pending changesets. |
pr-number | The pull request number that was created or updated. |
Notes
Without publish-script the action only maintains the Version Packages PR; publishing is opt-in.
Check out with fetch-depth: 0 so the action can compare changesets against full history.
Common errors
GitHub Actions is not permitted to create or approve pull requestsmeans the repo/org setting blocking Actions-created PRs is on. Enable it or use a PAT/App token asgithub-token.- An npm
ENEEDAUTHor 401 during publish meansNPM_TOKENis missing from the env or your publish script does not read it (e.g. no.npmrcwiring).
Security and pinning
- Use a granular npm automation token stored as a secret, scoped to only the packages this repo publishes.
- Pin the action to a commit SHA; it runs with
contents: writeand your npm credentials.
Alternatives and related
Frequently asked questions
Why does the action say there are no changesets?
npx changeset) for the action to have anything to version. The has-changesets output tells you whether any were pending.