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 in "projectRelationship": "independent" mode is not tagging and releasing projects that depend on projects that are getting published #22268

Closed
1 of 4 tasks
brugi82 opened this issue Mar 11, 2024 · 7 comments · Fixed by #23252

Comments

@brugi82
Copy link

brugi82 commented Mar 11, 2024

Current Behavior

nx release in "projectRelationship": "independent" mode is only tagging and releasing projects with changes. If there are projects that depend on these projects, they are not getting tagged and released.
For example, if we have 2 libraries, is-even and is-odd. is-odd has a dependency on package is-even that is correctly identified by dependency-checks eslint rule, and stated in it's package.json file. When changes are committed to package is-even and nx release is triggered, only that package is tagged for release. is-odd's package.json is getting updated, but the package is not getting released.

Our release configuration from nx.json:

  "release": {
    "version": {
      "conventionalCommits": true
    },
    "changelog": {
      "projectChangelogs": true
    },
    "projectsRelationship": "independent",
    "releaseTagPattern": "{projectName}-{version}"
  },
image image

Expected Behavior

We are expecting that with the changes made to the "root" package, release bubbles up to all packages that depend on that package too. In this concrete example, we are expecting that with the changes made to is-even package, nx release not only triggers and tags is-even package, but is-odd package too, as that one directly depends on is-even.

GitHub Repo

https://github.com/brugi82/nx-independent-monorepo

Steps to Reproduce

  1. Clone a repository
  2. Package is-odd depends on package is-even. is-even has one committed change that is not released.
  3. Execute nx release --skip-publish --dry-run --verbose
  4. Only package is-even is getting tagged & released.

Nx Report

nx                 : 18.0.7
@nx/js             : 18.0.7
@nx/linter         : 18.0.7
@nx/eslint         : 18.0.7
@nx/workspace      : 18.0.7
@nx/devkit         : 18.0.7
@nx/eslint-plugin  : 18.0.7
@nx/react          : 18.0.7
@nx/rollup         : 18.0.7
@nrwl/tao          : 18.0.7
@nx/vite           : 18.0.7
@nx/web            : 18.0.7
typescript         : 5.3.3

Failure Logs

No response

Package Manager Version

yarn 4.1.0

Operating System

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

Additional Information

I am willing to submit a PR that solves this problem.

@ryan-mcginty-alation
Copy link

This is also something I just ran into, as an example jscutlery has a --trackDeps flag which enables one to opt in to this behavior. Is there some setting somewhere that we can opt in for nx release that we are missing?

brugi82 pushed a commit to brugi82/nx that referenced this issue Mar 25, 2024
Propagate release for all dependant packages that need updating when projectRelationship is "independent" .
Fixes nrwl#22268
@edbzn
Copy link
Contributor

edbzn commented Mar 30, 2024

Hey, we're facing the same issue in our repository where the package @jscutlery/swc-angular-preset has implicit dependency + peer dependency on @jscutlery/swc-plugin-angular, yet when we release the swc-angular-preset project it doesn't bump the swc-plugin-angular including the peer dependency update.

@fahslaj
Copy link
Contributor

fahslaj commented Apr 3, 2024

Hey @edbzn and @brugi82, Nx Release doesn't update the version of is-odd in this case because it is unclear what the version bump for is-odd should be. Yes, its dependency on is-even was updated, but since they are independently versioned, there is no context for if is-even should be a patch, minor, or major version bump. There could be a major version of is-even released that does not change the core functionality of is-odd, so is-odd wouldn't need a major version bump.

@JamesHenry
Copy link
Collaborator

The PR to address this is ready for review here: #22836

@paulo9mv
Copy link

paulo9mv commented May 9, 2024

I have the following scenario:
app-A which imports lib-A and lib-B

With this fix, will it be required for lib-A and lib-B to have its own package.json, even if I don't version/release them? The only versioning/release is for app-A.

The package.json for app-A doesn't have the dependencies section, but a commit changing lib-A triggers affected for app-A. If I understood correctly, this fix will add the commit of lib-A to changelog since if affected app-A.

@fahslaj
Copy link
Contributor

fahslaj commented May 14, 2024

This will be addressed with #23252

FrozenPandaz pushed a commit that referenced this issue May 23, 2024
…ort circular dependencies (#23252)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

When releasing projects independently, if a dependent project is
untouched directly by the changes, it will not have its version updated
and there is no way to opt into this behavior.

Additionally, circular dependencies between packages are not supported.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

When releasing projects independently, if a dependent project is
untouched directly by the changes, **BY DEFAULT** it will not have its
version updated, **BUT** you can opt into it always being updated via a
generator option (`release.version.generatorOptions.updateDependents =
auto` and you can control what kind of semver bump should be applied to
the otherwise unchanged dependent project. Transitive local dependents
(`A -> B -> C`) will also be updated in this scenario.

Additionally, when opted into, such version only changes will appear in
the changelog under a new `Updated Dependencies` section.

Circular dependencies between packages are now supported for versioning,
changelog generation and publishing.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #22268
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 Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.