nx icon indicating copy to clipboard operation
nx copied to clipboard

Nx release doesn't update the right package.json files

Open njsokol opened this issue 1 year ago • 7 comments

Current Behavior

Context:

  • We have multiple packages in a repo and using independent releases
  • We are using release plans

Whats happening: When running nx release the correct versions of "to" are being interpreted and added to the output, but they are being added to the dist/package.json not the <package>/package.json

UPDATE packages/react-components/react-button/dist/package.json [dry-run]

    "name": "@company/react-button",
-   "version": "0.1.0",
+   "version": "0.1.1",
    "description": "A button component for the library",

    "dependencies": {
-     "@company/react-theme": "0.0.0"
+     "@company/react-theme": "0.1.0"
    },

  }
+

This is great in that it's updating the packages "/dist" because when I publish, all the versions are now correct in the published files and folders. But my problem is that then in the repo, if I were to run the release again, my source files are now saying the <package>/package.json is still at 0.1.0 and not 0.1.1 as it should have been from the previous release.

Expected Behavior

Doing the release should update the <package>/package.json file to match what was just published.

GitHub Repo

No response

Steps to Reproduce

Can't reproduce as the library is private

Nx Report

Node : 20.12.2 OS : linux-x64 Native Target : x86_64-linux pnpm : 8.15.8

nx : 20.0.3 @nx/js : 20.0.3 @nx/jest : 20.0.3 @nx/eslint : 20.0.3 @nx/workspace : 20.0.3 @nx/cypress : 20.0.3 @nx/devkit : 20.0.3 @nrwl/devkit : 18.3.3 @nx/eslint-plugin : 20.0.3 @nx/playwright : 20.0.3 @nx/plugin : 20.0.3 @nx/storybook : 20.0.3 @nrwl/tao : 19.8.8 @nx/vite : 20.0.3 @nx/web : 20.0.3 @nx/webpack : 20.0.3 typescript : 5.4.5

Registered Plugins: @nx/storybook/plugin @nx/eslint/plugin @nx/playwright/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • [ ] macOS
  • [x] Linux
  • [x] Windows
  • [ ] Other (Please specify)

Additional Information

No response

njsokol avatar Oct 29 '24 16:10 njsokol

I'm having a similar issue with version 20.1.0, where during the release process all dist/**/package.json get updated with the correct new version, but the packages/**/package.json still have 0.0.1, which was the original version.

This leads to another issue which is a subsequent run of the release for a package without changes will try to publish the 0.0.1 package again, and will fail (because it already exists, probably). No idea why the release step will do this though, since the dry run correctly identifies that the package has not been changed and should not be bumped nor should the changelog be generated

jgsmarques avatar Nov 15 '24 18:11 jgsmarques

Can confirm I and seeing the same thing with 20.4

sir-captainmorgan21 avatar Feb 24 '25 23:02 sir-captainmorgan21

Same thing in 21

marc-wilson avatar May 28 '25 04:05 marc-wilson

@njsokol @jgsmarques @sir-captainmorgan21 @marc-wilson

Not sure if it is well documented, but you can configure it with manifestRootsToUpdate, adjust the default value in project.json to:

{
 "release": {
    "version": {
      "manifestRootsToUpdate": ["dist/{projectRoot}", "{projectRoot}"],
    }
  }
}

And you should see the source package.json also adjusted.

viters avatar Jun 10 '25 12:06 viters

@njsokol @jgsmarques @sir-captainmorgan21 @marc-wilson

Not sure if it is well documented, but you can configure it with manifestRootsToUpdate, adjust the default value in project.json to:

yea, but the docs say that we shouldn't be updating or managing any versioning in files. It's all done via tags. The overall documentation of nx release needs to be revamped as it is poorly documented and missing critical detail.

marc-wilson avatar Jun 10 '25 18:06 marc-wilson

@marc-wilson Maybe, I wanted to keep them up to date only for the sake of clarity. I use versioning based on the registry. Should version fields from projects package.json be removed in this case?

viters avatar Jun 10 '25 18:06 viters

@marc-wilson Maybe, I wanted to keep them up to date only for the sake of clarity. I use versioning based on the registry. Should version fields from projects package.json be removed in this case?

For sure. I think that is one of the biggest questions. They outline 4 different scenarios in the docs and two of the scenarios seem to be geared towards that use case. But, the documentation menitions in the other scenarios, as well as in passing, that you shouldn't be doing versioning this way as nx release uses tags.

For my use case, I want to follow the git tags approach, but, it doesn't work in GitHub Actions which is a problem for me since i want to automate it. I have opened to https://github.com/nrwl/nx/issues/31378 to try and get some answers/fixes around it.

marc-wilson avatar Jun 10 '25 19:06 marc-wilson

Any updates @njsokol ? Happening to me too

fadymq avatar Sep 18 '25 19:09 fadymq