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 output wrong prerelease tag & versions both package.json #23235

Closed
1 of 4 tasks
kaankoken opened this issue May 8, 2024 · 8 comments · Fixed by #26524
Closed
1 of 4 tasks

nx release output wrong prerelease tag & versions both package.json #23235

kaankoken opened this issue May 8, 2024 · 8 comments · Fixed by #26524

Comments

@kaankoken
Copy link

Current Behavior

In mono repo configuration, independent mode, everything is perfectly fine when I run nx release version. However, whenever I try to create a prerelease with the flags of --specifier=prerelease --preid="rc" versioning goes so wrong.

  • The first problem is that when I try to run nx release version --preid="rc": it does not assign --specifier as prerelease. I have to assign it manually.
# Output

nx release version --verbose --preid="rc" --dry-run

 NX   Running release version for project: proj2

proj2 🔍 Reading data for package "proj2" from apps/proj2/package.json
proj2 📄 Resolved the current version as 0.2.0 from git tag "[email protected]".
proj2 📄 Resolved the specifier as "patch" using git history and the conventional commits standard.
proj2 ✍️  New version 0.2.1 written to apps/proj2/package.json

 NX   Running release version for project: proj1

proj1 🔍 Reading data for package "proj1" from apps/proj1/package.json
proj1 📄 Resolved the current version as 0.1.2 from git tag "[email protected]".
proj1 🚫 No changes were detected using git history and the conventional commits standard.
proj1 🚫 Skipping versioning "proj1" as no changes were detected.

UPDATE apps/proj2/package.json [dry-run]

    "private": true,
-   "version": "0.2.0"
+   "version": "0.2.1"
  }
  • The second problem is that when I introduced the specifier, it updated both package.json file
# Output

nx release version --verbose --preid="rc" --specifier=prerelease --dry-run

 NX   Running release version for project: proj2

proj2 🔍 Reading data for package "proj2" from apps/proj2/package.json
proj2 📄 Resolved the current version as 0.2.0 from git tag "[email protected]".
proj2 📄 Using the provided version specifier "prerelease".
proj2 ✍️  New version 0.2.1-rc.0 written to apps/proj2/package.json

 NX   Running release version for project: proj1

proj1 🔍 Reading data for package "proj1" from apps/proj1/package.json
proj1 📄 Resolved the current version as 0.1.2 from git tag "[email protected]".
proj1 📄 Using the provided version specifier "prerelease".
proj1 ✍️  New version 0.1.3-rc.0 written to apps/proj1/package.json

UPDATE apps/proj2/package.json [dry-run]

    "private": true,
-   "version": "0.2.0"
+   "version": "0.2.1-rc.0"
  }

UPDATE apps/proj1/package.json [dry-run]

    "private": true,
-   "version": "0.1.2"
+   "version": "0.1.3-rc.0"
  }
  • The last problem is that If the prerelease commit has BREAKING CHANGE or ! in a commit, it discards the breaking change part.

Commit Message: fix!: try prerelease

# prerelease output

nx release version --verbose --preid="rc" --specifier=prerelease --dry-run

 NX   Running release version for project: proj2

proj2 🔍 Reading data for package "proj2" from apps/proj2/package.json
proj2 📄 Resolved the current version as 0.2.0 from git tag "[email protected]".
proj2 📄 Using the provided version specifier "prerelease".
proj2 ✍️  New version 0.2.1-rc.0 written to apps/proj2/package.json

 NX   Running release version for project: proj1

proj1 🔍 Reading data for package "proj1" from apps/proj1/package.json
proj1 📄 Resolved the current version as 0.1.2 from git tag "[email protected]".
proj1 📄 Using the provided version specifier "prerelease".
proj1 ✍️  New version 0.1.3-rc.0 written to apps/proj1/package.json

UPDATE apps/proj2/package.json [dry-run]

    "private": true,
-   "version": "0.2.0"
+   "version": "0.2.1-rc.0"
  }

UPDATE apps/proj1/package.json [dry-run]

    "private": true,
-   "version": "0.1.2"
+   "version": "0.1.3-rc.0"
  }

# Release output

 nx release version --verbose --dry-run

 NX   Running release version for project: proj2

proj2 🔍 Reading data for package "proj2" from apps/proj2/package.json
proj2 📄 Resolved the current version as 0.2.0 from git tag "[email protected]".
proj2 📄 Resolved the specifier as "major" using git history and the conventional commits standard.
proj2 ✍️  New version 1.0.0 written to apps/proj2/package.json

 NX   Running release version for project: proj1

proj1 🔍 Reading data for package "proj1" from apps/proj1/package.json
proj1 📄 Resolved the current version as 0.1.2 from git tag "[email protected]".
proj1 🚫 No changes were detected using git history and the conventional commits standard.
proj1 🚫 Skipping versioning "proj1" as no changes were detected.

UPDATE apps/proj2/package.json [dry-run]

    "private": true,
-   "version": "0.2.0"
+   "version": "1.0.0"
  }






### Expected Behavior

For the first problem, when **--preid** is introduced as a command, it should assign `specifier` itself.
For the second problem, I do not except that both `package.json` to be updated.
For the last one, if the the latest tag was `proj2-v0.1.0`, and breaking change commit introduced to code base even if **prerelease** versioning enabled, I excepted to be version `proj2-v1.0.0-rc.0`

### GitHub Repo

_No response_

### Steps to Reproduce

1. Create a project with two **independent** package.
2. Add the configuration to `nx.json`
```bash
  "release": {
    "projects": [
      "apps/*"
    ],
    "projectsRelationship": "independent",
    "releaseTagPattern": "{projectName}@v{version}",
    "conventionalCommits": {
      "types": {
        "deps": {
          "semverBump": "patch"
        },
        "revert": {
          "semverBump": "patch"
        }
      }
    },
    "changelog": {
      "projectChangelogs": false,
      "workspaceChangelog": false
    },
    "version": {
      "conventionalCommits": true,
      "git": {
        "tag": true,
        "commit": true,
        "stageChanges": true
      }
    }
  },
  1. Create an initial versioning by running: nx release version --first-release
  2. Create a new commit & to check preid work on itself(for the first problem mentioned) run, nx release version --preid="rc"
  3. Create a new commit & run nx release version --preid="rc" --specifier=prerelease
  4. Create a new commit contains breaking change & run nx release version --preid="rc" --specifier=prerelease

Nx Report

NX   Report complete - copy this into the issue template

Node   : 21.7.3
OS     : darwin-arm64
pnpm   : 9.0.4

nx (global)    : 19.0.1
nx             : 19.0.0
@nx/js         : 19.0.0
@nx/workspace  : 19.0.0
@nrwl/tao      : 19.0.1
---------------------------------------
The following packages should match the installed version of nx
  - @nrwl/[email protected]

To fix this, run `nx migrate [email protected]`

Failure Logs

No response

Package Manager Version

pnpm --version 9.0.4

Operating System

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

Additional Information

No response

@kaankoken
Copy link
Author

any update @JamesHenry @FrozenPandaz ?

@kaankoken
Copy link
Author

@AgentEnder any updates?

@kaankoken
Copy link
Author

how may I help you to solve this issue @JamesHenry @AgentEnder @FrozenPandaz

@adamghowiba
Copy link

Would be good to get some love on this, because I'm facing a similar issue using the custom script to release.

Overall I do feel prereleases weren't really accounted for when building this. Any plans on increasing the documentation and support for prerelease?

Specifying "preid" in the releaseVersion function compltetly ignores it when using conventional-commits as a specifierSource

@JamesHenry
Copy link
Collaborator

This is on my list for tomorrow, I will review the provided information and revert with any clarifying questions

@JamesHenry
Copy link
Collaborator

This is addressed by #26524

@JamesHenry
Copy link
Collaborator

JamesHenry commented Jun 12, 2024

Example (after a breaking change to bar):

image

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 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants