@lchemist/semantic-release-monorepo v1.0.0
@lchemist/semantic-release-monorepo
Apply semantic-release
's automatic publishing to monorepo packages. Forked from pmowrer/semantic-release-monorepo
.
Features
- Enable independent versioning on each monorepo package.
- Generate independent release note & git tag for each monorepo package.
- Allow a single GitHub repository to contain many
npm
packages.
Major Diff
This fork uses <PACKAGE_NAME>@<VERSION>
as tag format and release note's version title (e.g. core@1.2.3
).
Install
npm install -D semantic-release @lchemist/semantic-release-monorepo
NOTE: semantic-release
and @lchemist/semantic-release-monorepo
must be accessible in each monorepo package. (Install both at root directory of monorepo if you use Lerna).
Usage
{
"branch": "main",
"extends": "@lchemist/semantic-release-monorepo"
}
With CLI:
semantic-release -e @lchemist/semantic-release-monorepo
How
This library modifies the context
object passed to semantic-release
plugins in the following way to make them compatible with a monorepo.
Instead of attributing all commits to a single package, commits are assigned to packages based on the files that a commit touched.
If a commit touched a file in or below a package's root, it will be considered for that package's next release. A single commit can belong to multiple packages and may trigger the release of multiple packages.
In order to avoid version collisions, generated git tags are namespaced using the given package's name: <package-name>@<version>
.
Step | Description |
---|---|
analyzeCommits | Filters context.commits to only include the given monorepo package's commits. |
generateNotes | Filters context.commits to only include the given monorepo package's commits.Modifies context.nextRelease.version to use the monorepo git tag format. The wrapped (default) generateNotes implementation uses this variable as the header for the release notes. Since all release notes end up in the same Github repository, using just the version as a header introduces ambiguity. |