Skip to content
Latchkey

changesets/action

Automate versioning and npm publishing for repos that use Changesets.

Official actionCategory: Release AutomationLatest v1View on GitHub

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

workflow (.yml)
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

InputDescriptionDefaultRequired
github-tokenThe GitHub token to use for authentication.${{ github.token }}No
publish-scriptThe command to use to build and publish packages.-No
version-scriptThe command to update version, edit CHANGELOG, read and delete changesets. Defaults to changeset version.-No
commit-messageThe commit message for the version commit.Version PackagesNo
pr-titleThe pull request title.Version PackagesNo
create-github-releasesWhether to create GitHub releases after publish.trueNo
commit-modeHow changes are pushed: "git-cli" or "github-api" (signed commits attributed to the token owner).git-cliNo

Outputs

OutputDescription
publishedBoolean indicating whether a publish happened.
published-packagesJSON array of published packages with name and version.
has-changesetsBoolean indicating whether there were pending changesets.
pr-numberThe 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 requests means the repo/org setting blocking Actions-created PRs is on. Enable it or use a PAT/App token as github-token.
  • An npm ENEEDAUTH or 401 during publish means NPM_TOKEN is missing from the env or your publish script does not read it (e.g. no .npmrc wiring).

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: write and your npm credentials.

Alternatives and related

Frequently asked questions

Why does the action say there are no changesets?
PRs must include a changeset file (from npx changeset) for the action to have anything to version. The has-changesets output tells you whether any were pending.

References

Running changesets/action? Run it on Latchkey managed runners - self-healing and caching included. Start free → 30-day trial · No credit card