Monorepo semantic-release Configuration

Configure semantic-release for monorepo projects with per-package releases. Use pkgRoot and exec plugin to handle multi-package repositories with independent versioning.

Advanced Configuration

Detailed Explanation

semantic-release in a Monorepo

Monorepos require special handling because each package needs independent versioning and publishing. There are several approaches, but the most common uses per-package configuration with the pkgRoot option.

Per-Package Configuration

Place a .releaserc.json in each package directory:

{
  "branches": ["main"],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    ["@semantic-release/npm", {
      "pkgRoot": "."
    }],
    ["@semantic-release/exec", {
      "prepareCmd": "npm run build"
    }],
    "@semantic-release/github"
  ]
}

Root-Level Configuration with Exec

For monorepos managed from the root, use @semantic-release/exec to run package-specific commands:

{
  "branches": ["main"],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    ["@semantic-release/exec", {
      "prepareCmd": "node scripts/update-versions.js ${nextRelease.version}",
      "publishCmd": "node scripts/publish-packages.js"
    }],
    "@semantic-release/github"
  ]
}

Filtering Commits by Path

To ensure each package only triggers releases based on its own changes, use the commit-analyzer with path filtering:

["@semantic-release/commit-analyzer", {
  "preset": "angular",
  "releaseRules": [
    {"type": "feat", "scope": "package-a", "release": "minor"},
    {"type": "fix", "scope": "package-a", "release": "patch"}
  ]
}]

Alternative: semantic-release-monorepo

The semantic-release-monorepo package extends semantic-release to automatically filter commits by package directory, making configuration simpler for large monorepos.

Use Case

Organizations with multiple related packages in a single repository (e.g., a component library with separate packages for React, Vue, and Angular wrappers) that need independent versioning and publishing for each package.

Try It — Semantic Release Config Builder

Open full tool