Skip to content

Release a monorepo

This guide shows how to release several packages from one repository. Each package is a scope, with its own version, changelog section, and tags.

List each package in scopes, with its path relative to the configuration file:

unirelman.config.ts
import { defineConfig } from "@unirelman/cli";
import { createChangelogPlugin } from "@unirelman/plugin-changelog";
import { createChangesetsPlugin } from "@unirelman/plugin-changesets";
import { createGitPlugin } from "@unirelman/plugin-git";
import { createNpmPlugin } from "@unirelman/plugin-npm";
import { createSemverPlugin } from "@unirelman/plugin-semver";
export default defineConfig({
scopes: {
"@example/core": "packages/core",
"@example/cli": "packages/cli",
"@example/ui": "packages/ui",
},
plugins: [
createChangesetsPlugin(),
createChangelogPlugin(),
createNpmPlugin(),
createGitPlugin(),
createSemverPlugin(),
],
});

Name each scope after its package: the name appears in tags and changelog sections. See scopes.

List the scopes of the change, separated by commas:

Terminal window
npx unirelman changesets create --scopes "@example/core,@example/ui" --level patch --message "fix a bug"

The npm plugin gives a change to the packages that depend on a released scope, and updates their dependency ranges. See Internal dependencies.

To update the dependents on every release of their dependency:

unirelman.config.ts
createNpmPlugin({ updateInternalDependencies: { dependents: "always" } });

The Changelog plugin writes one CHANGELOG.md at the root by default. To write one in each scope folder:

unirelman.config.ts
createChangelogPlugin({ mode: "scope" });

To give every scope the same version, use fixed versioning:

unirelman.config.ts
createSemverPlugin({ fixed: true });

To version only some scopes together, name the groups. The other scopes stay independent:

unirelman.config.ts
createSemverPlugin({
fixed: {
product: ["@example/core", "@example/cli"],
},
});

The scopes of a group start from the same current version.

Register each versioning plugin for its scopes:

unirelman.config.ts
import { defineConfig } from "@unirelman/cli";
import { createCalverPlugin } from "@unirelman/plugin-calver";
// ...
export default defineConfig({
scopes: {
"@example/core": "packages/core",
"@example/ui": "packages/ui",
},
plugins: [
createChangesetsPlugin(),
createChangelogPlugin(),
{
plugin: createSemverPlugin(),
scopes: ["@example/core"],
},
{
plugin: createCalverPlugin(),
scopes: ["@example/ui"],
},
// ...
],
});

Each scope with changes needs a plugin that reads its current version, such as npm, and one that computes its next version, such as SemVer or CalVer.

The root of the repository can be a scope too, such as a root package.json you also release:

unirelman.config.ts
scopes: {
root: "./",
"@example/core": "packages/core",
},

Its tags are the bare version, such as 1.0.1. See Tag names.