Although release-it was not originally designed for monorepos, certain workflows with multiple workspaces can still be installed.
If all workspaces should be bumped to the same version and are published at the same time, then follow the two steps in this guide.
- A single
npm run release
to publish each package, finishing with a run for the monorepo root. - Each package will be published one after another separately.
- The
version
in eachpackage.json
will be bumped. - All internal packages in
dependencies
anddevDependencies
will be bumped to the same version.
There is nothing fancy going on, this works with existing solutions. I did not test this with the conventional-changelog plugin. Currently using this setup myself in the 7-docs monorepo. See this commit that follows this guide.
- Install the bumper plugin:
npm install -D @release-it/bumper
- Order the
workspaces
so a workspace depending on another comes after it. See the examples below. - Add a
release
script to run therelease
script of all workspaces and end with itself. - Make sure it contains
git.requireCleanWorkingDir: false
(to include all updatedpackage.json
files) - Make sure to add
npm.publish: false
here if the root should not be published. - Add e.g.
github.release: true
and/or other changelog related tasks to the root config.
Example:
{
"name": "root-package",
"version": "1.0.0",
"workspaces": ["packages/a", "packages/b", "packages/c"],
"scripts": {
"release": "npm run release --workspaces && release-it"
},
"release-it": {
"git": {
"requireCleanWorkingDir": false
}
}
}
- Add a
"release": "release-it"
script to each workspace'spackage.json
. - Add a
release-it
config (either topackage.json
or in.release-it.json
) - Make sure it contains
git: false
- Add
@release-it/bumper
config if it has internal dependencies so thesedependencies
ordevDependencies
will be automatically bumped during the release-it process.
Example for a workspace without internal dependencies:
{
"name": "package-a",
"version": "1.0.0",
"scripts": {
"release": "release-it"
},
"dependencies": {},
"release-it": {
"git": false
}
}
Example for a workspace with internal dependencies:
{
"name": "package-c",
"version": "1.0.0",
"scripts": {
"release": "release-it"
},
"dependencies": {
"package-a": "1.0.0"
},
"devDependencies": {
"package-b": "1.0.0"
},
"release-it": {
"git": false,
"plugins": {
"@release-it/bumper": {
"out": {
"file": "package.json",
"path": ["dependencies.package-a", "devDependencies.package-b"]
}
}
}
}
}