action

Changesets Release Action

This action for Changesets creates a pull request with all of the package versions updated and changelogs updated and when there are new changesets on your configured baseBranch, the PR will be updated. When you’re ready, you can merge the pull request and you can either publish the packages to npm manually or setup the action to do it for you.

Usage

Inputs

Outputs

Example workflow:

Without Publishing

Create a file at .github/workflows/release.yml with the following content.

name: Release

on:
  push:
    branches:
      - main

concurrency: $-$

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4

      - name: Setup Node.js 24
        uses: actions/setup-node@v4
        with:
          node-version: 24

      - name: Install Dependencies
        run: yarn

      - name: Create Release Pull Request
        uses: changesets/action@v1

With Publishing

You can authenticate to npm with either:

  1. NPM_TOKEN — a classic npm token that can publish and does not require 2FA on publish (2FA on auth can still be enabled). Store it as a repo secret named NPM_TOKEN.
  2. npm trusted publishing (OIDC) — omit NPM_TOKEN and grant the job id-token: write so GitHub Actions can obtain an OIDC token. The action detects ACTIONS_ID_TOKEN_REQUEST_TOKEN / ACTIONS_ID_TOKEN_REQUEST_URL and skips writing an auth line to .npmrc.

When NPM_TOKEN is set, the action writes (or appends) this line to $HOME/.npmrc only if no existing npmjs auth line is present:

//registry.npmjs.org/:_authToken=<NPM_TOKEN>

If a user .npmrc already exists with an auth token for registry.npmjs.org, the action leaves it alone. If NPM_TOKEN is unset, the action does not write undefined into .npmrc (required for trusted publishing).

Example with NPM_TOKEN:

name: Release

on:
  push:
    branches:
      - main

concurrency: $-$

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4

      - name: Setup Node.js 24
        uses: actions/setup-node@v4
        with:
          node-version: 24

      - name: Install Dependencies
        run: yarn

      - name: Create Release Pull Request or Publish to npm
        id: changesets
        uses: changesets/action@v1
        with:
          # This expects you to have a script called release which does a build for your packages and calls changeset publish
          publish: yarn release
        env:
          NPM_TOKEN: $

      - name: Send a Slack notification if a publish happens
        if: steps.changesets.outputs.published == 'true'
        # You can do something when a publish happens.
        run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!"

Example with trusted publishing (no NPM_TOKEN):

jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org
      - run: yarn
      - uses: changesets/action@v1
        with:
          publish: yarn release

If you need a custom .npmrc, create it in a prior step; the action will not overwrite an existing auth token line for registry.npmjs.org:

- name: Creating .npmrc
  run: |
    cat << EOF > "$HOME/.npmrc"
      //registry.npmjs.org/:_authToken=$NPM_TOKEN
    EOF
  env:
    NPM_TOKEN: $

Custom Publishing

If you want to hook into when publishing should occur but have your own publishing functionality, you can utilize the hasChangesets output.

Note that you might need to account for things already being published in your script because a commit without any new changesets can always land on your base branch after a successful publish. In such a case you need to figure out on your own how to skip over the actual publishing logic or handle errors gracefully as most package registries won’t allow you to publish over already published version.

name: Release

on:
  push:
    branches:
      - main

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4

      - name: Setup Node.js 24
        uses: actions/setup-node@v4
        with:
          node-version: 24

      - name: Install Dependencies
        run: yarn

      - name: Create Release Pull Request or Publish to npm
        id: changesets
        uses: changesets/action@v1

      - name: Publish
        if: steps.changesets.outputs.hasChangesets == 'false'
        # You can do something when a publish should happen.
        run: yarn publish

With version script

If you need to add additional logic to the version command, you can do so by using a version script.

If the version script is present, this action will run that script instead of changeset version, so please make sure that your script calls changeset version at some point. All the changes made by the script will be included in the PR.

name: Release

on:
  push:
    branches:
      - main

concurrency: $-$

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4

      - name: Setup Node.js 24
        uses: actions/setup-node@v4
        with:
          node-version: 24

      - name: Install Dependencies
        run: yarn

      - name: Create Release Pull Request
        uses: changesets/action@v1
        with:
          # this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
          version: yarn version

With Yarn 2 / Plug’n’Play

If you are using Yarn Plug’n’Play, you should use a custom version command so that the action can resolve the changeset CLI:

- uses: changesets/action@v1
  with:
    version: yarn changeset version
    ...