mikepenz/release-changelog-builder-action

'1.2.3.dev0' not identified as pre-release

wadevries opened this issue · 7 comments

Hi @mikepenz, thanks for this project, it (almost) exactly fits my needs.

In my project I tag pre-releases like 1.2.3.dev0, 1.2.3.dev1 etc. When releasing a 'final' release (e.g. 1.2.3) I want to fromTag to be 1.2.2, not 1.2.3.dev1, so I set ignorePreReleases: true. However, this doesn't work the way I expected.

My suspicion is that this line is the reason (as my version doesn't include a -):

if (!tags[ii].name.includes('-')) {
return tags[ii]
}

Would it be an idea to offer a preReleaseMatcher option, similar to the other filter options?
Example:

{
  "preReleaseMatcher": {
    "pattern": "\\.dev\d+$",
    "flags": "gu"
  }
}

for my case. It could default to ".*-.*" or such.

I'd be happy to work on a PR if this is something that would be acceptable.

Thank you very much for raising the ticket.

Yes you are absolutely right, that the linked block of code is the reason for this.

While not the perfect solution, you probably could already "fix" it with APIs available right now. Using a tagTransformer:
https://github.com/mikepenz/release-changelog-builder-action/blob/91da901770452fde84cadec921d0740a850780db/pr-collector/src/tags.ts#L251C18-L265
Which would practically allow you to add the - for pre releases. However I do agree this is not the best solution.

That being said. I wonder if it may be worth to see if we can solve it combining the capabilities of the semver library which is already in place.

https://github.com/mikepenz/release-changelog-builder-action/blob/91da901770452fde84cadec921d0740a850780db/pr-collector/src/tags.ts#L256C6-L260

E.g. if we construct the TagInfo add a new field to remember if it is a pre-release and fill this with info from semVer and if it's not semVer apply the old logic for the string sorting. (e.g. -)

this would probably open it up for other versioning schemes in the future if applicable.

Thanks, I did not think of the trick/hack with adding a - using a tagTransformer.

I was also thinking of using some semver parsing library for this, but digging into this it seems that I'm not adhering to semver, stricktly speaking! https://semver.org/#spec-item-9. So the semver library will also not accept it. Apparently the current implementation is technically correct, because a - is only allowed for pre-release indicators.

I guess for me the best thing to do now is to actually use the tagTransformer for its documented purpose; to transform my tags to valid semver.

E.g. if we construct the TagInfo add a new field to remember if it is a pre-release and fill this with info from semVer and if it's not semVer apply the old logic for the string sorting. (e.g. -)

This does sound the way to go imho.

this would probably open it up for other versioning schemes in the future if applicable.

Well, not sure how though, as the semver library rejects my 1.2.3.dev0. But maybe I misunderstood.

Alas, I also need to strip a prefix, as in api/v1.2.3.dev0. I need to transform that to 1.2.3-dev0.

My tagTransformer currently looks like

"transformer": {
  "pattern": "\\.dev",
  "target": "-dev"
}

but that only handles the dev part. The earlier transformer I had was

"transformer": {
  "pattern": "^api/v",
  "target": ""
}

But there's no way to combine those two. I've been trying to come up with a clever regex replacement that can do both these things but to no avail. If only I could specify an array of transformers 😉

Hi mike, you have done a great job by providing release note generator.i'm currently using it on my local for study purpose. how can i create my custom release note.Need help in this

@ajaybmin I think this is the wrong place to ask for this. Please create a new issue if you have specific questions

@wadevries would you please be so kind to try out: #1141 which allows you to pass an [] of Transformer instead of a single Transformer only.

you can use it

mikepenz/release-changelog-builder-action@cd529e70570b092a385a56d2ce7b70dca2d47e70

Added the [] for tag transformers in the latest release