Skip to content

Version Modes ​

The three version modes of a monorepo (unified, selective, independent), what each one bumps, tags and writes, with an example per mode.

A project without monorepo config is a single package (standalone): its root package.json is bumped, tagged v1.2.3 and published. In a monorepo, monorepo.versionMode decides how the packages matched by monorepo.packages are versioned:

ts
import { defineConfig } from 'relizy'

export default defineConfig({
  monorepo: {
    versionMode: 'selective',
    packages: ['packages/*'],
  },
})

Comparison ​

unifiedselectiveindependent
Packages bumpedAllThe ones with commits, and their dependentsThe ones with commits, and their dependents
VersionThe root version, for every packageThe root version, for the bumped packagesEach package its own, from its own commits
Root package.jsonBumpedBumpedNot bumped
Git tagsOne: v1.2.0One: v1.2.0One per package: @scope/[email protected]
ChangelogsRoot CHANGELOG.md and one per packageRoot CHANGELOG.md and one per bumped packageOne per bumped package, and a root CHANGELOG.md aggregating them
lerna.jsonversion updatedversion updatedNot updated
Best forTightly coupled packages, always used togetherMany packages sharing a version line, not all changingPackages with their own lifecycle

In every mode:

  • the root version (unified, selective) is computed from the commits of the released packages: a commit changing no package (CI, scripts, an ignored package, a private package left out by privatePackages) releases nothing. The commits changing files outside every package (CI, scripts, the lockfile) are still listed in the root changelog of a release;
  • a package gets the commits changing its directory (see Moving & Renaming Packages for the moves), and the commits changing a catalog entry it uses;
  • the dependents follow bump.dependencyTypes and the out-of-range peer dependencies, see Dependency Management;
  • the tag format comes from templates.tagBody for the repository tag, the package tags are always <name>@<version>.

The bump type comes from the commits (see Semver Convention), or from a flag such as --minor.

Unified ​

Every package gets the root version, even without commits of its own:

text
                  Before   After a feat commit in packages/ui
root              1.4.2    1.5.0
packages/core     1.4.2    1.5.0
packages/utils    1.4.2    1.5.0
packages/ui       1.4.2    1.5.0
Tag: v1.5.0

Use it when the packages are always installed together and their versions must match.

Selective ​

The root version is bumped from the commits, and only the packages with commits (and their dependents) get it. The others keep their version:

text
                  Before   After a feat commit in packages/core
root              1.4.2    1.5.0
packages/core     1.4.2    1.5.0    commits
packages/ui       1.4.2    1.5.0    depends on @scope/core
packages/utils    1.4.2    1.4.2    not released
Tag: v1.5.0

A package not released for a while jumps to the root version on its next release: packages/utils goes from 1.4.2 to the root version of that release (1.6.1, say), not to 1.4.3. A dependent always gets the root version, never a patch of its own version.

Use it for most monorepos: one version line, without releasing unchanged packages.

Independent ​

Each package is bumped from its own commits, from its own version. A dependent without commits of its own gets a patch (with --prerelease, a prepatch, or the next prerelease when it already is a prerelease). The root package.json keeps its version:

text
                  Before   After a feat commit in packages/core, a fix in packages/utils
root              1.0.0    1.0.0
packages/core     2.0.0    2.1.0    feat
packages/ui       0.8.3    0.8.4    depends on @scope/core
packages/utils    1.3.5    1.3.6    fix
Tags: @scope/[email protected], @scope/[email protected], @scope/[email protected]

The previous release of a package is its last <name>@<version> tag. A package without a tag of its current version starts at the commit that set this version in its package.json (see Moving Packages to an Independent Group).

Use it when the packages evolve at different paces, with their own major versions.

The root version, with its v* tags and its changelog, belongs to the unified and selective modes. To keep one next to independent packages, release them as version groups: a selective group owns the root version, an independent group releases the other packages.

Switching Modes ​

Change monorepo.versionMode; nothing is rewritten until the next release:

  • From independent to unified/selective: the next release gives the new root version to the packages it bumps (all of them in unified, the changed ones in selective). The previous release is then read from the repository tags (v1.2.3), not from the package tags.
  • From unified/selective to independent: each package continues from its own version, and starts at the commit that set it when it has no <name>@<version> tag yet.

Preview the first release in the new mode with relizy release --dry-run.

Mixing Modes ​

To release some packages in selective mode and others in independent mode in the same run, use version groups.