Skip to content

Commit

Permalink
chore(release): add nx release recipes (#21294)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj authored Jan 24, 2024
1 parent 81d8428 commit d9c53e1
Show file tree
Hide file tree
Showing 8 changed files with 719 additions and 0 deletions.
90 changes: 90 additions & 0 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,39 @@
],
"disableCollapsible": false
},
{
"name": "Nx Release",
"path": "/recipes/nx-release",
"id": "nx-release",
"isExternal": false,
"children": [
{
"name": "Get Started with Nx Release",
"path": "/recipes/nx-release/get-started-with-nx-release",
"id": "get-started-with-nx-release",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Release Projects Independently",
"path": "/recipes/nx-release/release-projects-independently",
"id": "release-projects-independently",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Automatically Version with Conventional Commits",
"path": "/recipes/nx-release/automatically-version-with-conventional-commits",
"id": "automatically-version-with-conventional-commits",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
},
{
"name": "Other",
"path": "/recipes/other",
Expand Down Expand Up @@ -4177,6 +4210,63 @@
"children": [],
"disableCollapsible": false
},
{
"name": "Nx Release",
"path": "/recipes/nx-release",
"id": "nx-release",
"isExternal": false,
"children": [
{
"name": "Get Started with Nx Release",
"path": "/recipes/nx-release/get-started-with-nx-release",
"id": "get-started-with-nx-release",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Release Projects Independently",
"path": "/recipes/nx-release/release-projects-independently",
"id": "release-projects-independently",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Automatically Version with Conventional Commits",
"path": "/recipes/nx-release/automatically-version-with-conventional-commits",
"id": "automatically-version-with-conventional-commits",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"disableCollapsible": false
},
{
"name": "Get Started with Nx Release",
"path": "/recipes/nx-release/get-started-with-nx-release",
"id": "get-started-with-nx-release",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Release Projects Independently",
"path": "/recipes/nx-release/release-projects-independently",
"id": "release-projects-independently",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Automatically Version with Conventional Commits",
"path": "/recipes/nx-release/automatically-version-with-conventional-commits",
"id": "automatically-version-with-conventional-commits",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "Other",
"path": "/recipes/other",
Expand Down
123 changes: 123 additions & 0 deletions docs/generated/manifests/nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3256,6 +3256,51 @@
"path": "/recipes/nx-console",
"tags": []
},
{
"id": "nx-release",
"name": "Nx Release",
"description": "Recipes for releasing with Nx release.",
"mediaImage": "",
"file": "",
"itemList": [
{
"id": "get-started-with-nx-release",
"name": "Get Started with Nx Release",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/get-started-with-nx-release",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/get-started-with-nx-release",
"tags": ["nx-release"]
},
{
"id": "release-projects-independently",
"name": "Release Projects Independently",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/release-projects-independently",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/release-projects-independently",
"tags": ["nx-release"]
},
{
"id": "automatically-version-with-conventional-commits",
"name": "Automatically Version with Conventional Commits",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/automatically-version-with-conventional-commits",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/automatically-version-with-conventional-commits",
"tags": ["nx-release"]
}
],
"isExternal": false,
"path": "/recipes/nx-release",
"tags": []
},
{
"id": "other",
"name": "Other",
Expand Down Expand Up @@ -5724,6 +5769,84 @@
"path": "/recipes/nx-console/console-troubleshooting",
"tags": ["integrate-with-editors"]
},
"/recipes/nx-release": {
"id": "nx-release",
"name": "Nx Release",
"description": "Recipes for releasing with Nx release.",
"mediaImage": "",
"file": "",
"itemList": [
{
"id": "get-started-with-nx-release",
"name": "Get Started with Nx Release",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/get-started-with-nx-release",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/get-started-with-nx-release",
"tags": ["nx-release"]
},
{
"id": "release-projects-independently",
"name": "Release Projects Independently",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/release-projects-independently",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/release-projects-independently",
"tags": ["nx-release"]
},
{
"id": "automatically-version-with-conventional-commits",
"name": "Automatically Version with Conventional Commits",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/automatically-version-with-conventional-commits",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/automatically-version-with-conventional-commits",
"tags": ["nx-release"]
}
],
"isExternal": false,
"path": "/recipes/nx-release",
"tags": []
},
"/recipes/nx-release/get-started-with-nx-release": {
"id": "get-started-with-nx-release",
"name": "Get Started with Nx Release",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/get-started-with-nx-release",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/get-started-with-nx-release",
"tags": ["nx-release"]
},
"/recipes/nx-release/release-projects-independently": {
"id": "release-projects-independently",
"name": "Release Projects Independently",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/release-projects-independently",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/release-projects-independently",
"tags": ["nx-release"]
},
"/recipes/nx-release/automatically-version-with-conventional-commits": {
"id": "automatically-version-with-conventional-commits",
"name": "Automatically Version with Conventional Commits",
"description": "",
"mediaImage": "",
"file": "shared/recipes/nx-release/automatically-version-with-conventional-commits",
"itemList": [],
"isExternal": false,
"path": "/recipes/nx-release/automatically-version-with-conventional-commits",
"tags": ["nx-release"]
},
"/recipes/other": {
"id": "other",
"name": "Other",
Expand Down
23 changes: 23 additions & 0 deletions docs/generated/manifests/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,29 @@
"path": "/recipes/tips-n-tricks/flat-config"
}
],
"nx-release": [
{
"description": "",
"file": "shared/recipes/nx-release/get-started-with-nx-release",
"id": "get-started-with-nx-release",
"name": "Get Started with Nx Release",
"path": "/recipes/nx-release/get-started-with-nx-release"
},
{
"description": "",
"file": "shared/recipes/nx-release/release-projects-independently",
"id": "release-projects-independently",
"name": "Release Projects Independently",
"path": "/recipes/nx-release/release-projects-independently"
},
{
"description": "",
"file": "shared/recipes/nx-release/automatically-version-with-conventional-commits",
"id": "automatically-version-with-conventional-commits",
"name": "Automatically Version with Conventional Commits",
"path": "/recipes/nx-release/automatically-version-with-conventional-commits"
}
],
"database": [
{
"description": "",
Expand Down
25 changes: 25 additions & 0 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,31 @@
}
]
},
{
"name": "Nx Release",
"id": "nx-release",
"description": "Recipes for releasing with Nx release.",
"itemList": [
{
"name": "Get Started with Nx Release",
"id": "get-started-with-nx-release",
"tags": ["nx-release"],
"file": "shared/recipes/nx-release/get-started-with-nx-release"
},
{
"name": "Release Projects Independently",
"id": "release-projects-independently",
"tags": ["nx-release"],
"file": "shared/recipes/nx-release/release-projects-independently"
},
{
"name": "Automatically Version with Conventional Commits",
"id": "automatically-version-with-conventional-commits",
"tags": ["nx-release"],
"file": "shared/recipes/nx-release/automatically-version-with-conventional-commits"
}
]
},
{
"name": "Other",
"id": "other",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Automatically Version with Conventional Commits

If you wish to bypass the versioning prompt, you can configure Nx Release to defer to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard to determine the version bump automatically. This is useful for automating the versioning process in a CI/CD pipeline.

## Enable Automatic Versioning

To enable automatic versioning via conventional commits, set the `release.version.conventionalCommits` property to `true` in `nx.json`:

```json nx.json
{
"release": {
"version": {
"conventionalCommits": true
}
}
}
```

## Determine the Version Bump

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:

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

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.

{% callout type="info" title="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](/recipes/nx-release/release-projects-independently) as well, allowing for only some projects to be released and some to be skipped.
{% /callout %}

## Usage with Independent Releases

If you are using [independent releases](/recipes/nx-release/release-projects-independently), Nx Release will determine the version bump for each project independently. For example, if the git history looks like this:

```
- fix(pkg-1): fix something
- feat(pkg-2): add a new feature
- chore(pkg-3): update docs
- chore(release): publish
```

Nx Release will select the `patch` version bump for `pkg-1` and `minor` for `pkg-2`. `pkg-3` will be skipped entirely, since it has no `feat` or `fix` commits.

{% callout type="info" title="Determining if a commit affects a project" %}
Note that this determination is made based on files changed by each commit, _not_ by the scope of the commit message itself. This means that `feat(pkg-2): add a new feature` could trigger a version bump for a project other than `pkg-2` if it updated files in another project.
{% /callout %}

An example partial output of running Nx Release with independent releases and conventional commits enabled:

```{% command="nx release" %}
> NX Running release version for project: pkg-1
pkg-1 🔍 Reading data for package "@myorg/pkg-1" from packages/pkg-1/package.json
pkg-1 📄 Resolved the current version as 0.4.0 from git tag "[email protected]".
pkg-1 📄 Resolved the specifier as "minor" using git history and the conventional commits standard.
pkg-1 ✍️ New version 0.5.0 written to packages/pkg-1/package.json
> NX Running release version for project: pkg-2
pkg-2 🔍 Reading data for package "@myorg/pkg-2" from packages/pkg-2/package.json
pkg-2 📄 Resolved the current version as 0.4.0 from git tag "[email protected]".
pkg-2 📄 Resolved the specifier as "patch" using git history and the conventional commits standard.
pkg-2 ✍️ New version 0.4.1 written to packages/pkg-2/package.json
pkg-2 ✍️ Applying new version 0.4.1 to 1 package which depends on pkg-2
> NX Running release version for project: pkg-3
pkg-3 🔍 Reading data for package "@myorg/pkg-3" from packages/pkg-3/package.json
pkg-3 📄 Resolved the current version as 0.4.0 from git tag "[email protected]".
pkg-3 🚫 No changes were detected using git history and the conventional commits standard.
pkg-3 🚫 Skipping versioning "@myorg/pkg-3" as no changes were detected.
```
Loading

1 comment on commit d9c53e1

@vercel
Copy link

@vercel vercel bot commented on d9c53e1 Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.