Skip to content
Latchkey

How to Release a Monorepo With lerna version and lerna publish

lerna version bumps changed packages and creates git tags; lerna publish then ships those tagged versions to the registry.

Lerna detects which packages changed since the last release, bumps them (from prompts or conventional commits), commits, tags, and pushes with lerna version. lerna publish from-git then publishes exactly the tagged versions.

Steps

  • Set version mode in lerna.json (independent or a fixed version string).
  • Run lerna version --conventional-commits to bump, tag, and push.
  • Run lerna publish from-git to publish the tagged versions.
  • Provide NODE_AUTH_TOKEN so publish can authenticate to npm.

lerna.json

lerna.json
{
  "version": "independent",
  "npmClient": "pnpm",
  "command": {
    "version": {
      "conventionalCommits": true,
      "createRelease": "github"
    }
  }
}

Terminal

Terminal
# Bump, changelog, tag, and push in CI
npx lerna version --conventional-commits --yes

# Publish exactly what was just tagged
npx lerna publish from-git --yes

Gotchas

  • from-git publishes the versions in the tags Lerna just created, avoiding a second bump.
  • Independent mode tags each package as name@x.y.z; fixed mode uses a single vX.Y.Z tag.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →