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/actionwith apublishcommand. - On merges it either opens the version PR or publishes.
- Provide
NPM_TOKENfor 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
How to Publish an npm Package in GitHub ActionsPublish an npm package from GitHub Actions on a release - set up the registry with the auth token, run npm pu…
How to Auto-Update a Changelog in GitHub ActionsAutomatically generate and commit changelog entries in GitHub Actions from conventional commits, so CHANGELOG…