mooltiverse / nyx

The one stop semantic release tool
https://github.com/mooltiverse/nyx
Apache License 2.0
116 stars 8 forks source link

[QUESTION] support for appending build metadata to the version output #317

Closed fredleger closed 1 week ago

fredleger commented 5 months ago

Hello,

Trying to setup nyx for building an helm chart stored in the rancher catalog format. For compatibility issue i need the version generated on branches other than main to respect the format x.y.z+build-meatadata. This is totaly semver valid according to https://semver.org/#spec-item-10 but how can i produce such a string using nyx ? tried with --bump=my-meta but it leads to x.y.z-my-meta.1 which is not supported by rancher (although it's also semver valid)

Thank you for any clue you can have

flelli commented 5 months ago

Hi @fredleger ,

the --bump flag indeed doesn't bump the build component, which is what you want to bump as far as I understand (since you're using the + separator). --bump only sets the major, minor, patch or pre-release components.

What is not clear to me is whether you want to generate a version number based on the Git commit history or by some other values you manage outside of Git. In the first case, just commit your work and let Nyx infer the version number for you, without overriding any value. In the second case Nyx may not be the right tool for you as it's primarily intended to work on the commit history.

Can you give some more details on your use case so I can give you better hints?

fredleger commented 5 months ago

Hi @flelli

sorry re-reading this i realize it wasn't clear enough

nyx infer --verbosity=INFO --summary --bump=alpha
INFO[0001] Version: '2.3.21-alpha.1'                    
branch           = ci/1st-implementation
bump             = alpha
core version     = false
latest version   = false
new release      = false
new version      = true
scheme           = SEMVER
timestamp        = 1718108563576
current version  = 2.3.21-alpha.1
previous version = 2.3.21
prime version    = 2.3.21

Found this issue relative to it : https://github.com/rancher/rancher/issues/24863

So i understand there is an in issue in rancher catalog processing since nyx does the job generating semver compatible version numbers but can i work around it in some way with nyx ?

flelli commented 5 months ago

Ok , I got it better now,

If you want to just make Rancher happy yes, you can just replace the + sign with -. This would be syntactically correct, but semantics would be mangled because the pre-release part (after the -) is not the same as the build part (after the +) from a SemVer perspective. Also consider that a SemVer compliant version might also have both.

From the example you gave I understand you override the bump just to add the pre-release identifier (although you need it to be a build identifier) to a core version number (with just major, minor and patch). I also see you're not in a main branch, so it's reasonable for you to tag with non-core versions.

Long story short, you can configure Nyx by adding a release type that matches your branch (ci/1st-implementation or anything you need) that creates versions numbers using any identifier you need. Based on the example above you just need to add the identifier with alpha as the qualifier in the BUILD position.

You can find some examples of release type configurations here or you can use a preset.