Publishing libraries to NPM
Publish flow is built on changesets.
Template includes GitHub Actions workflow for automated publishing.
You may install Changeset Bot to improve your experience
Changesets can work correctly with a monorepository and provide full control over the publication of packages, thanks to atomic manual specification of each change you want to describe.
Probably, it's looks some verbose compared to automatic changelogs, but in practice it's much more useful to have control and be able to fix anything before it's published.
So, changesets already installed and preconfigured a bit:
- Actual changesets configuration placed in .changeset/config.json, you can see config details in changesets documentation
- GitHub Action in .github/workflows/release.yaml
release-version
andrelease-publish
scripts in root package.json, it used inside GitHub Action, you can cut and inline it there if you want
Setup
Install changeset bot into your repository
Add
NPM_TOKEN
secret (npm access token) to GitHub Secrets.You can see more in changeset action documentation
Workflow
Really very simple:
- Add changesets
- Create and merge PR
- Technical "Version bump" PR will be automatically created, it will contain deletions of all changesets and updates of versions and changelogs
- Merge it technical PR
- Changed packages will be automatically published
You can add changesets anytime and in any quantity, changesets will save them all until packages will be published
yarn changeset
Recipes
Pin version
If you want sync packages version
Prevent publication
{
"ignore": ["@my-org/foo"]
}