qoomon / maven-git-versioning-extension

This extension will set project version, based on current Git branch or tag.
GNU General Public License v3.0
305 stars 87 forks source link

Support valid semver versions #246

Open reitzmichnicht opened 1 year ago

reitzmichnicht commented 1 year ago

Hi

Best extension ever, but I stumpled upon some incompatibilities with some other ecosystems. We are using this extension to determine the version of maven projects from the branch name. Sadly its mostly not possible to restrict the branch naming itself, and we use the branch name as the prerelease part for semantic versioning. https://semver.org/spec/v2.0.0.html#backusnaur-form-grammar-for-valid-semver-versions

Semantic versioning fails if the branch name contains characters not allowed for the prerelease part. Maven itself does not care about it, but when reusing the same generated version for e.g. npm parts of the project it fails. So it would be great to have an option to make some variables compatible to be used as prerelease or build part of the semver string.

Kind regards, Michael

qoomon commented 1 year ago

Could you give some examples of invalid prerelease values?

jstsddg commented 1 year ago

We are experiencing exactly the same problem (also with npm). For us the problem are underscores _ inside of the branch name (slug), npm will refuse these versions:

Version: {describe.tag.version}-${ref}.${describe.distance} feature/i_did_a_thing -> 1.0.0-feature-i_did_a_thing.99 should be 1.0.0-feature-i-did-a-thing.99

qoomon commented 1 year ago

Would it make sense to you to have an option to set the slug characters?

frans-otogone commented 1 year ago

Yes it would!