mbarkhau / bumpver

BumpVer: Automatic Versioning
https://github.com/mbarkhau/bumpver
MIT License
199 stars 36 forks source link

Allow custom suffix / tag #165

Closed cswan-log closed 1 year ago

cswan-log commented 3 years ago

Currently the TAG is fairly restricted. It would be great if this can be used more broadly.

For example we are releasing frequent "dev" versions which are build from the "develop" branch. Those are suffixed with -dev-SHA_OF_COMMIT to identify them as dev builds from a specific commit. This is needed since we currently using semver and the dev builds do not change the main version string which results in build like 2.1.0-dev-ahka131. Also the production builds are suffixed with the commit hash which allows us to link them directly with a commit.

Would it be possible to allow more different tags or a custom suffix?

mbarkhau commented 3 years ago

Isn't the ask here for a new part SHA_OF_COMMIT rather than anything to do with the TAG part?

mbarkhau commented 3 years ago

Hmm, I guess the issue with that might be the ordering of versions. 2.1.0-dev-ahka131 > 2.1.0-dev-131ahka though the latter might in fact be more recent.

cswan-log commented 3 years ago

Yeah, the ordering would be a bit wonky with this... So maybe a completetly custom suffix would be better suited for this situation? Thus when you are using it, you are aware that the ordering might be broken since the data is completetly up to you.

Related to the tag, the question was if it could be more broadly in terms of possible values or if this is restricted by the PEP schema? Any value like pre, dev etc. are useful but are forbidden with the current implementation.

mbarkhau commented 3 years ago

For the TAG part I think it would be ok to have other values. Currently the restriction is applied via this:

VALID_RELEASE_TAG_VALUES = ("alpha", "beta", "rc", "post", "final")

This could instead be taken from a config setting (accepting that pep440 normalization might be an issue).

Merinorus commented 2 years ago

Hi, I would also be interested in adding custom tags. In my case, I would like to tag an intermediate version with a particular feature, even if it's a pre-release, so I can have a reference for this feature later on. Eg:

I would prefer being able to simply write --tag=mycustomfeature. The difficulty, I guess, would be how the regex would apply if the tag isn't at the end of the string.

mbarkhau commented 2 years ago

The difficulty, I guess, would be how the regex would apply if the tag isn't at the end of the string.

I'm not sure that's a big issue. The syntax for optional parts translates to optional groups in a regex.

bumpver_pattern = "MAJOR.MINOR[.PATCH]"
regex_pattern = re.compile(r"""
    (?P<major>[0-9]+)
    \.
    (?P<minor>[0-9]+)
    (?:\.
        (?P<patch>[0-9]+)
    )?
""", flags=re.VERBOSE)

As I said with my comment from June 1st, ordering may be an issue. Currently the order for tags is well defined. If you can pick any string, which version is earlier than the other?

Merinorus commented 2 years ago

Oh, I see. In my case, I always increment the patch (or the last digit part in the general case). Eg:

I order the release with digits only.

I guess you can or cannot use lexicographical ordering depending on the versioning logic, and if you want to ensure order in your release, you should use a pattern that should maintain lexicographical ordering.

mbarkhau commented 2 years ago

Sounds like a foot-gun, but if people know what they're doing, I'm inclined to not stand in their way. If you want to work on a PR for this, I'll be happy to help you along.

For people who don't want to use this feature, I'd prefer to not just accept any value for --tag <NAME>. Instead the config can enable this behavior with a setting allow_custom_tags and only then bumpver would just accept whatever is given as a parameter. I think valid tags would have to match [a-z][a-z0-9_]*

Merinorus commented 2 years ago

Seems good to me! I'll think about a PR in this way.

Merinorus commented 2 years ago

Hello, Sorry but I don't think I will be able to work on it soon. I'm trying to find out how this works but this takes more time than I expected... If someone wants to take this one, feel free to spy on my branch: https://github.com/merinorus/bumpver/tree/allow-custom-tag

sharonyogev commented 1 year ago

For the TAG part I think it would be ok to have other values. Currently the restriction is applied via this:

VALID_RELEASE_TAG_VALUES = ("alpha", "beta", "rc", "post", "final")

This could instead by taken from a config setting (accepting that pep440 normalization might be an issue).

I've opened this PR here: https://github.com/mbarkhau/bumpver/pull/199

mbarkhau commented 1 year ago

Thanks @sharonyogev I'll have time to look at this later this month.