Automate independent versioning and publishing of packages in a monorepo.
Commit messages in the following format are required
<type>(<scope>): <subject>
<scope>
should be the name of the package intended to be released. The commit message format follows the angular commit message guidelines.
Note: for <scope>
don't include the @scope/
prefix of the package (only the package name).
Commit message examples
feat(package-a): add stuff to package-a
fix(package-b): fix something in package-b
BREAKING CHANGE:
Description of the breaking changes caused by the fix to package-b
Commit message CLI
A commit message CLI builder like cz-customisable can be included in your project to ensure commit messages are always formatted correctly.
This project uses cz-customisable (see project configuration file).
Requires initial package git tags to exist before the release()
function can be used to automate versioning and publishing
@scope/[email protected]
@scope/[email protected]
Generate tags manually or run a function available in this package to generate initial tags across current packages
Create initial tags: scripts/createTags.js
const { createTag, getPackages } = require('monorepo-release');
const packages = getPackages();
packages.forEach(createTag());
Run script
node scripts/createTags.js
Release: scripts/release.js
const { getPackages, release } = require('monorepo-release');
const packages = getPackages();
const config = {
dryRun: true,
};
packages.forEach(release(config));
Run script locally or in CI
node scripts/release.js
Package changelogs can be generated with something like auto-changelog by setting the changelog command (changelogCmd
) that is run (for each package)
Install auto-changelog
in project
yarn add --dev auto-changelog
packages/package-a/package.json
"scripts": {
"changelog": "auto-changelog"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"tagPattern": "@scope/package-a@"
}
scripts/release.js
const { getPackages, release } = require('monorepo-release');
const packages = getPackages();
const config = {
changelog: true,
changelogCmd: 'yarn changelog',
};
packages.forEach(release(config));
Run script locally or in CI
node scripts/release.js