Semver
Nx plugin to automate semantic versioning and CHANGELOG generation.
Install / Use
/learn @jscutlery/SemverREADME
@jscutlery/semver
Nx plugin for versioning using SemVer and CHANGELOG generation powered by Conventional Commits.
Setup
Install
npm install -D @jscutlery/semver
nx g @jscutlery/semver:install
This package allows you to manage your Nx workspace using one of two modes: Synced or Independent.
Independent mode (default)
Allow multiple projects to be versioned independently. This way you release only what you want and consumers don't get updates they don't need. This allows small, rapid and incremental adoption of your packages.
Synced mode
Allow multiple projects to be versioned in a synced/locked mode. Use this if you want to automatically tie all package versions together. This mode is useful when you are working with only one product. One issue with this approach is that a major change in any project will result in all projects having a new major version.
Usage
Release
Independent mode
Release project independently by running:
nx run my-project:version [...options]
You can leverage the affected command to only version changed packages:
nx affected --target version [...options]
Synced mode
Release workspace by running:
nx run workspace:version [...options]
When run, this executor does the following
- Retrieve the current version by looking at the last
git tag. - Bump
package.jsonversion based on the commits. - Generates CHANGELOG based on the commits (uses conventional-changelog-angular under the hood).
- Creates a new commit including the
package.jsonfile and updated CHANGELOG. - Creates a new tag with the new version number.
- Pushes the version to the remote repository.
- Runs post-targets hook to publish the version on NPM, GitHub or GitLab.
Available options
| name | type | default | description |
| ---------------------------- | ------------------ | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --dryRun | boolean | false | run with dry mode |
| --noVerify | boolean | false | skip git hooks |
| --enforceAtomicPush | boolean | false | enforce an atomic push without retrying a non atomic one in case of failure |
| --push | boolean | false | push the release to the remote repository |
| --syncVersions | boolean | false | lock/sync versions between projects |
| --skipRootChangelog | boolean | false | skip generating root changelog |
| --skipProjectChangelog | boolean | false | skip generating project changelog |
| --origin | string | 'origin' | push against git remote repository |
| --baseBranch | string | 'main' | push against git base branch |
| --changelogHeader | string | undefined | custom Markdown header for changelogs |
| --releaseAs | string | undefined | specify the level of change (details) |
| --preid | string | undefined | specify the prerelease identifier (eg: alpha, beta) (details) |
| --tagPrefix | string | undefined | specify the tag prefix (details) |
| --postTargets | string[] | [] | specify the list of target to execute post-release (details) |
| --trackDeps | boolean | false | bump dependent packages (bump A if A depends on B) (details) |
| --allowEmptyRelease | boolean | false | force a patch increment even if library source didn't change |
| --skipCommitTypes | string[] | [] | treat commits with specified types as non invoking version bump (details) |
| --skipCommit | boolean | false | skips generating a new commit, leaves all changes in index, tag would be put on last commit (details) |
| --skipStage | boolean | false | skips add to git stage, useful when you want to run nx cmd in parallel (details) |
| --commitMessageFormat | string | undefined | format the auto-generated message commit (details) |
| --preset | string \| object | 'angular' | customize Conventional Changelog options (details) |
| --commitParserOptions | object | undefined | customize the commit parserConfig (details) |
Guides
Overwrite default configuration
You can customize the default configuration using the definition file:
{
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"preset": "atom",
"tagPrefix": "{projectName}@"
}
}
Customizing Conventional Changelog
This tool comes with a list of pre-configured presets:
- angular (default)
- conventionalcommits
- angular (default)
- conventionalcommits
- atom
- codemirror
- ember
- eslint
- express
- jquery
- jshint
The preset is highly configurable, following the [conventional-changelog-config-spec](https://github.com/conventional-changelog/conventi
