jscutlery / semver

Nx plugin to automate semantic versioning and CHANGELOG generation.
MIT License
719 stars 83 forks source link

release does not consider prerelease tags #808

Open sidyes opened 2 months ago

sidyes commented 2 months ago

Due to the changes in #433 pre-release tags are ignored when getting the target release version.

Problem

If a prelease is started using the --releaseAs=prerelease parameter then it is fine as it takes the previous commits into account to identify the correct version. If a prerelease is started using premajor, preminor or prepatch then it might lead to (in my opinion) wrong release versions when performing the actual release.

Example

Let's assume an app named myapp having the version target and the current version 1.2.0 with the latest tag myapp-v.1.2.0

In the next step we want to create a new premajor release candidate: nx run myapp:version --releaseAs=premajor --preid=rc This leads to a new prerelease tag myapp-v.2.0.0-rc.0

Next, we add a few changes/commits and perform another prerelease: nx run myapp:version --releaseAs=prerelease This leads to a new prerelease tag myapp-v.2.0.0-rc.1.

Finally, we create a new release:
nx run myapp:version
This leads to a new release tag myapp-v.1.3.0 because it identifies the release to be a minor one due to the previous commits. It ignores the manually set premajor. The only way to "fix" this for me would be to add releaseAs=major to my command.

Expected Behavior

It should be a configurable option whether prerelease tags should be considered for getting the release version to support my scenario so that I do not have to specify the release version via releaseAs anymore as the release version should always match the pre-release version.
Or is there another way (currently) to achieve my goal?