docs/recipes/monorepo.md
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.
npm run release to publish each package, finishing with a run for the monorepo root.version in each package.json will be bumped.dependencies and devDependencies 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.
npm install -D @release-it/bumperworkspaces so a workspace depending on another comes after it. See the examples below.release script to run the release script of all workspaces and end with itself.git.requireCleanWorkingDir: false (to include all updated package.json files)npm.publish: false here if the root should not be published.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
}
}
}
"release": "release-it" script to each workspace's package.json.release-it config (either to package.json or in .release-it.json)git: false@release-it/bumper config if it has internal dependencies so these dependencies or devDependencies 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"]
}
}
}
}
}