Skip to content
Latchkey

How to Set Up a Monorepo Release with Changesets in GitHub Actions

Versioning many packages by hand is error-prone; Changesets turns accumulated changeset files into one version PR and a publish.

Use changesets/action, which opens a "Version Packages" PR from pending changesets and runs your publish command once that PR merges.

Steps

  • Initialize Changesets and have contributors add changeset files.
  • Add changesets/action with a publish command.
  • On merges it either opens the version PR or publishes.
  • Provide NPM_TOKEN for the publish step.

Workflow

.github/workflows/release.yml
name: Release
on:
  push:
    branches: [main]
permissions:
  contents: write
  pull-requests: write
jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20' }
      - run: npm ci
      - uses: changesets/action@v1
        with:
          publish: npm run release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →