This PR updates `nx release` to use the revamped versioning
implementation by default. It also updates and adds relevant
documentation, and provides an automated migration for the new
configuration structure.
For anyone exclusively versioning TS/JS packages, there should be no
real difference to your experience (although a number of bugs have been
fixed and new features around updating multiple `package.json` files at
once are now available to you with this change).
For the lifecycle of Nx v21, `release.version.useLegacyVersioning` will
remain as a option that can be set to `true` to revert to the old
behavior and configuration structure.
NOTE: This should only be a temporary solution, for example if one of
the plugins you use does provide a `VersionActions` based versioning
implementation yet. The option and legacy implementation will be removed
entirely in Nx v22 (in ~6 months).
BREAKING CHANGE:
**⚠️ For any early adopters of `VersionActions` in Nx 20.8 when it was
opt-in, there are breaking changes to the abstract class here as well.**
`manifestRootsToUpdate` has gone from `string[]` to `manifestsToUpdate:
{ manifestPath: string; preserveLocalDependencyProtocols: boolean; }[]`
to support controlling the local dependency updates per manifest in
order to support advanced source vs dist scenarios, and correspondingly
`isLocalDependencyProtocol` has been removed from the abstract class and
the method will no longer be called from the core logic. It should be
thought of as an implementation detail of `updateProjectDependencies`
instead.
40 lines
1.6 KiB
Markdown
40 lines
1.6 KiB
Markdown
---
|
|
title: Build Before Versioning
|
|
description: Learn how to configure Nx Release to build your projects before applying version updates, ensuring that distribution files are properly generated before publishing.
|
|
---
|
|
|
|
# Build Before Versioning
|
|
|
|
In order to ensure that projects are built before the new version is applied to their package manifest, you can use the `preVersionCommand` property in `nx.json`:
|
|
|
|
```json {% fileName="nx.json" %}
|
|
{
|
|
"release": {
|
|
"version": {
|
|
"preVersionCommand": "npx nx run-many -t build"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
This command will run the `build` target for all projects before the version step of Nx Release. Any command can be specified, including non-nx commands. This step is often required when [publishing from a custom dist directory](/recipes/nx-release/updating-version-references#scenario-2-i-want-to-publish-from-a-custom-dist-directory-and-update-references-in-my-both-my-source-and-dist-packagejson-files), as the dist directory must be built before the version is applied to the dist directory's package manifest.
|
|
|
|
When using release groups in which the member projects are versioned together, you can use `groupPreVersionCommand` and it will be executed before the versioning step for that release group.
|
|
|
|
```json {% fileName="nx.json" %}
|
|
{
|
|
"release": {
|
|
"groups": {
|
|
"my-group": {
|
|
"projects": ["my-lib-one", "my-lib-two"],
|
|
"version": {
|
|
"groupPreVersionCommand": "npx nx run-many -t build -p my-lib-one,my-lib-two"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
The `groupPreVersionCommand` will run in addition to the global `preVersionCommand`.
|