Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release): revamped nx release version implementation #30418

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

JamesHenry
Copy link
Collaborator

@JamesHenry JamesHenry commented Mar 18, 2025

This PR provides a new implementation for the versioning stage of nx release which brings a ton of benefits.

Previously unsupported/impossible features now available:

  • It is possible to have dependencies which flow across release group boundaries, therefore updateDependents will work across group boundaries as well.
  • It is possible to update multiple manifests (such as package.json) for a single versioning execution. For example, updating the version and dependencies in both your source and dist package.json for a project.

Massively improved extensibility for non-JS languages/ecosystems:

  • The ReleaseVersionGenerator abstraction was distinctly suboptimal because it required each plugin to reimplement a bunch of core business logic related to resolving tags from git, combining current versions and specifiers to produce new semver values, deleting version plans after use etc.
    • It is now been replaced by the VersionActions class, which exclusively deals with the aspects that make that language/ecosystem unique, such as reading and writing from a manifest file (such as package.json/Cargo.toml etc) if applicable, reading from a remote registry etc.
    • No core business logic about releases is handled within a VersionActions implementation.
    • You can check out the implementation for JS projects here: packages/js/src/generators/release-version/version-actions.ts

Other benefits:

  • More performant
  • Much better IDE experience for version configuration because of the untyped generatorOptions going away, and most options moving to the top level of release.version config in nx.json.
  • More informative logs during versioning, e.g.
    • BEFORE: Resolved the specifier as "minor" using version plans.
    • AFTER: Applied semver relative bump "minor", read from version plan .nx/version-plans/bump-mixed1.md, to get new version 0.2.0
  • Lays the groundwork for application releases becoming a first-class use-case as part of our 2025 Roadmap.
  • preserveLocalDependencyProtocols is now true by default and can be omitted from end user configs.

Notes on rollout

  • In Nx v20, it is opt-in via setting "useLegacyVersioning": false in release.version in nx.json.
  • It will be enabled by default in Nx v21, with opt-out still possible via setting the flag explicitly to true.
  • We will provide an automated migration to the new configuration as part of Nx v21
  • The legacy versioning can now be considered "frozen". Some bugs should be fixed by moving to the new versioning, and any future fixes will be applied there.
  • In Nx v22, the legacy versioning will be entirely removed.
  • Documentation updates will take place in a follow up PR which documents both approaches, whilst making it clear that the legacy versioning is being replaced.

You can see how straightforward it was to manually apply using the PR release from this branch on a real world project here: angular-eslint/angular-eslint#2329


Fixes #21458
Fixes #21466
Fixes #26444
Fixes #27823
Fixes #28049
Fixes #28695
Fixes #30363

Copy link

vercel bot commented Mar 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Mar 28, 2025 5:13pm

Copy link

nx-cloud bot commented Mar 18, 2025

View your CI Pipeline Execution ↗ for commit 6fbe6c1.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 33m 22s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 16s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 3s View ↗
nx-cloud record -- nx format:check --base=90ff0... ✅ Succeeded 5s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 1s View ↗
nx documentation ✅ Succeeded 49s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-28 17:51:42 UTC

@nrwl nrwl deleted a comment from github-actions bot Mar 24, 2025
@JamesHenry JamesHenry marked this pull request as ready for review March 24, 2025 12:49
@JamesHenry JamesHenry requested review from meeroslav, vsavkin, mandarini and a team as code owners March 24, 2025 12:49
export default class JsVersionActions extends VersionActions {
manifestFilename = 'package.json';

static createAfterAllProjectsVersionedCallback(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: not a fan of this method name. Is postVersioning callback a better name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is now an exported function as discussed. I couldn't help feeling like afterAllProjectsVersioned is a clearer name because it's not after all of the version logic runs (it's before git for example), so postVersion felt a little ambiguous

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But I have indeed been able to flatten it now too and avoid the higher order function

@nrwl nrwl deleted a comment from github-actions bot Mar 27, 2025
@nrwl nrwl deleted a comment from github-actions bot Mar 27, 2025
Copy link

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx create-nx-workspace@0.0.0-pr-30418-80f02f7 my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-30418-80f02f7
Release details 📑
Published version 0.0.0-pr-30418-80f02f7
Triggered by @JamesHenry
Branch nx-release-v-v2
Commit 80f02f7
Workflow run 14115494427

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

@nrwl nrwl deleted a comment from github-actions bot Mar 27, 2025
Copy link

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx create-nx-workspace@0.0.0-pr-30418-6fbe6c1 my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-30418-6fbe6c1
Release details 📑
Published version 0.0.0-pr-30418-6fbe6c1
Triggered by @JamesHenry
Branch nx-release-v-v2
Commit 6fbe6c1
Workflow run 14135844180

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants