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 not pushing the changes to source-control #22073

Closed
1 of 4 tasks
zoran995 opened this issue Feb 29, 2024 · 7 comments · Fixed by #29280
Closed
1 of 4 tasks

nx release not pushing the changes to source-control #22073

zoran995 opened this issue Feb 29, 2024 · 7 comments · Fixed by #29280

Comments

@zoran995
Copy link
Contributor

Current Behavior

When running nx release in ci without creating a new github release nx won't push the changes to source-control meaning the version change won't be reflected in repo/project package.json, and the commit won't be properly tagged in a git. On subsequent runs of nx release it will try to publish the same version again but it won't be able to overwrite the version on npm.
This leads to an entirely broken CI process for us as it is not possible to release new versions, as a workaround we can add git push and git push --tags but that isn't written anywhere in the documentation. Only place mentioning pushing changes is next to the changelog config

Generate a changelog for one or more projects, and optionally push to Github
it doesn't mention anything about specific cases in which push will happen

If we set "createRelease": "github" it will push the changes to repo but that works only with github

Expected Behavior

After nx release is run and the new version is generated changes should be pushed to the source control and it should matter if we configured it to generate a changelog or GitHub release, of course, those should be grouped in one commit but the one shouldn't have to think if something is going to break since version change and the tag wasn't pushed to the source control.

Also, I would argue that there shouldn't be a need to configure the user name and email for git, but that should be handled through configuration and set up on ci if not defined already

GitHub Repo

No response

Steps to Reproduce

  1. Create new nx based project
  2. Create a package set the version to i.e. 1.0.0 and commit the changes
  3. Setup the nx release
    i.e. I used this
  "release": {
    "releaseTagPattern": "release/{version}",
    "projects": ["*", "!private"],
    "version": {
      "conventionalCommits": true
    },
    "git": {
      "commit": true,
      "tag": true,
      "commitMessage": "chore(release): {version} [skip ci]"
    },
    "changelog": {
      "workspaceChangelog": false,
      "projectChangelogs": {
        "renderOptions": {
          "authors": false
        }
      }
    }
  },
  1. run the first release
  2. configure ci to run nx release
    i.e. I used this to publish to GitHub packages
jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v3
        with:
          node-version: 20
          cache: 'npm'
          registry-url: https://npm.pkg.github.com/
      - run: npm ci
      - uses: nrwl/nx-set-shas@v3
      - run: npx nx format:check
      - run: npx nx affected -t build
      - run: git config --global user.email "release-bot<>"
      - run: git config --global user.name "Release bot"
      - run: npx nx release -y --verbose
        env:
          NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
  1. commit the changes as feature commit, feat: configure ci
  2. push the change, it will run the ci which will publish version 1.1.0
  3. observe that there is no push commit anywhere in ci log, also check the source control and notice that there is no commit chore(release): 1.1.0 [skip ci]
  4. create a new fix commit and push the changes
  5. ci is started once again, but now it publishes version 1.1.0 again although we would expect version 1.1.1

Nx Report

Node   : 20.9.0
OS     : darwin-arm64
npm    : 10.1.0

nx                 : 18.0.5
@nx/js             : 18.0.5
@nx/jest           : 18.0.5
@nx/linter         : 18.0.5
@nx/eslint         : 18.0.5
@nx/workspace      : 18.0.5
@nx/devkit         : 18.0.5
@nx/eslint-plugin  : 18.0.5
@nx/react          : 18.0.5
@nrwl/tao          : 18.0.5
@nx/web            : 18.0.5
@nx/webpack        : 18.0.5
typescript         : 5.3.3

Failure Logs

the first run
 NX   Running release version for project: org

org 🔍 Reading data for package "@zoran995/nx-playground-org" from apps/org/package.json
org 📄 Resolved the current version as 1.10.0 from git tag "release/1.10.0".
org 📄 Resolved the specifier as "minor" using git history and the conventional commits standard.
org ✍️  New version 1.11.0 written to apps/org/package.json

UPDATE apps/org/package.json

    "name": "@zoran995/nx-playground-org",
-   "version": "1.10.0",
+   "version": "1.11.0",
    "repository": {


 NX   Updating npm lock file

Updating package-lock.json with the following command:
npm install --package-lock-only

 NX   Staging changed files with git

Staging files in git with the following command:
git add apps/org/package.json package-lock.json

 NX   Generating an entry in apps/org/CHANGELOG.md for release/1.11.0


UPDATE apps/org/CHANGELOG.md

+ ## 1.11.0 (2024-02-29)
+
+
+ ### 🚀 Features
+
+ - add console.log again1111
+
+
+ ### 🩹 Fixes
+
+ - remove manual push from ci
+
+ - add console.log again
+
+ - removing console.log
+
  ## 1.10.0 (2024-02-29)




the second run 


 NX   Running release version for project: org

org 🔍 Reading data for package "@zoran995/nx-playground-org" from apps/org/package.json
org 📄 Resolved the current version as 1.10.0 from git tag "release/1.10.0".
org 📄 Resolved the specifier as "minor" using git history and the conventional commits standard.
org ✍️  New version 1.11.0 written to apps/org/package.json

UPDATE apps/org/package.json

    "name": "@zoran995/nx-playground-org",
-   "version": "1.10.0",
+   "version": "1.11.0",
    "repository": {


 NX   Updating npm lock file

Updating package-lock.json with the following command:
npm install --package-lock-only

 NX   Staging changed files with git

Staging files in git with the following command:
git add apps/org/package.json package-lock.json

 NX   Generating an entry in apps/org/CHANGELOG.md for release/1.11.0


UPDATE apps/org/CHANGELOG.md

+ ## 1.11.0 (2024-02-29)
+
+
+ ### 🚀 Features
+
+ - add console.log again1111
+
+
+ ### 🩹 Fixes
+
+ - remove manual push from ci
+
+ - add console.log again
+
+ - removing console.log
+
+ - change console.log message
+
  ## 1.10.0 (2024-02-29)

Package Manager Version

No response

Operating System

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

Additional Information

No response

@zoran995 zoran995 changed the title nx release not pushing the changes to soru nx release not pushing the changes to source-control Feb 29, 2024
@melishev
Copy link

melishev commented Apr 7, 2024

This is really very unexpected behavior for me, as someone who just started migrating all repositories: 6 nest.js and vue.js applications and 5 packages for them.

Before that I used semantic-release library in github action for each of the repositories and was happy, here I was expecting to see something similar, but I didn't find an adequate solution in the end.

It seems to me that the nx publish command should have a --CI option, which will automate all the processes described above, and replicate the semantic-release functionality at the expense of the nx functions

@jbsouvestre
Copy link

Hello, this is an issue for us because we're on gitlab so we can't set the github release option

Here's the relevant snippet : https://github.com/nrwl/nx/blob/master/packages/nx/src/command-line/release/release.ts#L205-L225

Seems like the gitPush() could be lifted outside the condition of checking if you should create a workspace release (if (shouldCreateWorkspaceRelease && changelogResult.workspaceChangelog) )

Are you accepting PRs regarding this issue ?

@lorenyaSICKAG
Copy link

Same problem here.

@ccreusat
Copy link

Same here 😪

@aPinix
Copy link

aPinix commented Sep 30, 2024

Do you happen to have any news on this? This is a must, and it seems it's not working for some months 😅 Can you please fix this? Thanks in advance

@tuga49
Copy link

tuga49 commented Sep 30, 2024

Any updates regarding this issue? Thanks

@JamesHenry
Copy link
Collaborator

JamesHenry commented Dec 10, 2024

Hi Folks, I'm sorry for the delay on this one, as noted it has always been possible to workaround by adding git push or deep importing our gitPush utility function when using our first class programmatic API, but PR #29280 formally makes it a supported feature to automate the git push even when not using github releases.

There should be no breaking change, push will always default to false on the version subcommand, and default to false for the changelog subcommand except when a github release has been opted into.

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

Successfully merging a pull request may close this issue.

9 participants