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

NX release is not correctly bumping dependant projects when using conventional commits #26592

Closed
1 of 4 tasks
Warrper opened this issue Jun 18, 2024 · 3 comments
Closed
1 of 4 tasks

Comments

@Warrper
Copy link

Warrper commented Jun 18, 2024

Current Behavior

I have a monorepo with a project graph that has a similar structure to this:
image

When using nx release if I create a commit that changes @wp-test/test-package-a, currently we get the following console output:

 NX   Running release version for project: @wp-test/test-package-c

@wp-test/test-package-c 🔍 Reading data for package "@wp-test/test-package-c" from packages/folder-b/folder-c/package-c/package.json
@wp-test/test-package-c 📄 Resolved the current version as 1.1.0 from git tag "@wp-test/test-package-c@1.1.0".
@wp-test/test-package-c 🚫 No changes were detected using git history and the conventional commits standard.
@wp-test/test-package-c 🚫 Skipping versioning "@wp-test/test-package-c" as no changes were detected.

 NX   Running release version for project: @wp-test/test-package-d

@wp-test/test-package-d 🔍 Reading data for package "@wp-test/test-package-d" from packages/folder-b/folder-c/package-d/package.json
@wp-test/test-package-d 📄 Resolved the current version as 1.1.0 from git tag "@wp-test/test-package-d@1.1.0".
@wp-test/test-package-d 🚫 No changes were detected using git history and the conventional commits standard.
@wp-test/test-package-d 🚫 Skipping versioning "@wp-test/test-package-d" as no changes were detected.

 NX   Running release version for project: @wp-test/test-package-a

@wp-test/test-package-a 🔍 Reading data for package "@wp-test/test-package-a" from packages/folder-a/package-a/package.json
@wp-test/test-package-a 📄 Resolved the current version as 1.1.0 from git tag "@wp-test/test-package-a@1.1.0".
@wp-test/test-package-a 📄 Resolved the specifier as "patch" using git history and the conventional commits standard.
@wp-test/test-package-a ✍️  New version 1.1.1 written to packages/folder-a/package-a/package.json

 NX   Running release version for project: @wp-test/test-package-b

@wp-test/test-package-b 🔍 Reading data for package "@wp-test/test-package-b" from packages/folder-b/package-b/package.json
@wp-test/test-package-b 📄 Resolved the current version as 1.1.0 from git tag "@wp-test/test-package-b@1.1.0".
@wp-test/test-package-b 🚫 No changes were detected using git history and the conventional commits standard.
@wp-test/test-package-b 🚫 Skipping versioning "@wp-test/test-package-b" as no changes were detected.

In this scenario the only package that gets updated is package-a, despite the fact that I have version.generatorOptions.updateDependents = 'auto'

Expected Behavior

I would expect that all packages that depend on package-a would also get updated as part of this release.

GitHub Repo

No response

Steps to Reproduce

  1. Create a monorepo with a dependency structure matching this graph:
    image
  2. use nx release with the following release config:
{
    "projects": [
      "packages/**/*"
    ],
    "projectsRelationship": "independent",
    "changelog": {
      "automaticFromRef": true,
      "projectChangelogs": {
        "file": false,
        "createRelease": "github"
      }
    },
    "version": {
      "conventionalCommits": true,
      "generatorOptions": {
        "updateDependents": "auto",
        "fallbackCurrentVersionResolver": "disk"
      }
    }
  }
  1. create a nx-release.ts with code that looks like this:
    const versionOutput = await releaseVersion({
      dryRun: false,
      verbose: true,
      gitCommit: false,
      gitTag: true,
    });

    const releaseOutput = await releasePublish({
      dryRun: false,
      verbose: true,
      outputStyle: 'stream',
    });

    console.log('versionOutput', JSON.stringify(versionOutput, null, 4));
    console.log('releaseOutput', releaseOutput);

The important part here is that gitCommit is false.

  1. Run your initial release and see that everything bumps fine.
  2. Run another release with only a change to package-a and observe that only package a updates rather than package a and its dependencies

Nx Report

Node   : 20.11.0
OS     : darwin-arm64
yarn   : 1.22.21

nx             : 18.3.5
@nx/js         : 18.3.5
@nx/workspace  : 18.3.5
@nx/devkit     : 18.3.5
@nrwl/tao      : 18.3.5
typescript     : 5.3.3

Failure Logs

No response

Package Manager Version

yarn 1.22.21

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

After digging around the code I belive the issue lies here:

specifier = await resolveSemverSpecifierFromConventionalCommits(

Because we are passing gitCommit false to version (we manage versions entierly using tags) when it looks through your commits for 'relevent' commits

export async function getCommitsRelevantToProjects(
it will only return commits for package-a (as that's the only package that actually has a commited change).

version.generatorOptions.updateDependents = 'auto' that it would also update package-a's dependent packages rather than just the package itself.

The commit to package-a is 'relevent' to b,c and d because they depend on package-a

@rcolwell-cb
Copy link

Seems like same behavior as this. @JamesHenry @FrozenPandaz
#26041

@JamesHenry
Copy link
Collaborator

This was answered on #26041, in this case it is down to the old version of Nx being used

@JamesHenry JamesHenry closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2024
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants