Customize Conventional Commit Types

Nx Release can defer to the Conventional Commits standard to automatically determine the next version to release. To enable this behavior for versioning, see Automatically Version with Conventional Commits.

This recipe will cover how to customize the types of commits that trigger version bumps, how to customize the version bump for each type, and how to customize the changelog entry for each commit type.

Conventional Commits Usage within Nx Release

The conventional commits configuration is used in two different places within Nx Release - once in the version step for determining the version bump, and once when generating changelogs.

Determine the Version Bump

When release.version.conventionalCommits is true in nx.json, Nx Release will use the commit messages since the last release to determine the version bump. It will look at the type of each commit and determine the highest version bump from the following list:

  • 'feat' -> minor
  • 'fix' -> patch

For example, if the git history looks like this:

1 - fix(pkg-1): fix something 2 - feat(pkg-2): add a new feature 3 - chore(pkg-3): update docs 4 - chore(release): 1.0.0 5

then Nx Release will select the minor version bump and elect to release version 1.1.0. This is because there is a feat commit since the last release of 1.0.0. To customize the version bump for different types of commits, or to trigger a version bump with custom commit types, see the Configure Commit Types section below.

No changes detected

If Nx Release does not find any relevant commits since the last release, it will skip releasing a new version. This works with independent releases as well, allowing for only some projects to be released and some to be skipped.

Breaking Changes and Major Version Bumps

Major version bumps are triggered by the presence of a BREAKING CHANGE in the footer of the commit message or with '!' after the commit type and scope, as specified by the Conventional Commits standard. This is regardless of the type or scope of the commit. For example:

1fix: remove deprecated config properties 2 3BREAKING CHANGE: `settings` and `overrides` keys in config are no longer supported 4
1fix!: do not trigger a workflow when user submits bad data 2
1feat(pkg-2)!: redirect users to the new workflow page 2

When Nx Release detects a breaking change, it will bump the major version, regardless of the other commits present in the history. Breaking changes will also appear in their own section of the changelog.

Generate Changelog Sections

Nx Release will sort changes within changelogs into sections based on the type of commit. By default, fix, feat, and perf commits will be included in the changelog. To customize the headers of changelog sections, include other commit types, or exclude the default commit types, see the Configure Commit Types section below.

See the Nx repo for an example of a changelogs generated with Nx Release.

Configure Commit Types

Commit types are configured in the release.conventionalCommits.types property in nx.json:

nx.json
1{ 2 "release": { 3 "conventionalCommits": { 4 "types": { 5 // disable the fix type for versioning and in the changelog 6 "fix": false, 7 "docs": { 8 "semverBump": "patch", 9 "changelog": { 10 "hidden": false, 11 "title": "Documentation Changes" 12 } 13 }, 14 "perf": { 15 "semverBump": "none", 16 // omitting "hidden" will default it to false 17 "changelog": { 18 "title": "Performance Improvements" 19 } 20 }, 21 "deps": { 22 "semverBump": "minor", 23 // omitting "hidden" will default it to false 24 "changelog": { 25 "title": "Dependency Updates" 26 } 27 }, 28 // unspecified semverBump will default to "patch" 29 "chore": { 30 // "changelog.hidden" defaults to true, but setting changelog: false 31 // is a shortcut for setting "changelog.hidden" to false. 32 "changelog": false 33 }, 34 // unspecified semverBump will default to "patch" 35 "styles": {} 36 } 37 } 38 } 39} 40

In this example, the following types are configured:

  • The fix type has been fully disabled, so fix commits will not trigger a version bump and will not be included in the changelog.
  • The docs type will trigger a patch version bump and will have the "Documentation Changes" title in the changelog.
  • The perf type will NOT trigger a version bump and will have the "Performance Improvements" title in the changelog.
  • The deps type will trigger a minor version bump and will have the "Dependency Updates" title in the changelog.
  • The chore type will trigger a patch version bump, which is the default for if versionBump is not specified, and will not be included in the changelog.
  • The styles type will trigger a patch version bump, which is the default for if versionBump is not specified, and will be included in the changelog with the corresponding default title.