metadata-action icon indicating copy to clipboard operation
metadata-action copied to clipboard

semver tag : allow outputing build information (part after plus)

Open Murazaki opened this issue 1 year ago • 6 comments

Description

Please allow outputting "+" prefixed information in semver tags, as some of us uses it for fork versioning.

Murazaki avatar Feb 10 '24 07:02 Murazaki

Can you show an example of versioning? It should be compliant with https://semver.org/

crazy-max avatar Feb 10 '24 08:02 crazy-max

I'm working on a fork. The upstream has a base semver version : 2.3.8 (git tag v2.3.8) My fork adds on top of that : 2.3.8+fork.1.0.1 (git tag v2.3.8+fork.1.0.1) Type=semver gives a build tag like this : 2.3.8

It would be better to be able to show that particular info in the docker tag : 2.3.8+fork.1.0.1

Of course it doesn't need to be default, and it can be on a per name basis. I was envisioning a variable addBuildInfo=<true|false> or addBuildInfo=<nameToPickUp> (for instance addBuildInfo=fork)

Murazaki avatar Feb 10 '24 11:02 Murazaki

Thanks for your feedback. I don't think we need an extra variable, build metadata for semver should be included whatever the case.

crazy-max avatar Feb 13 '24 09:02 crazy-max

Thanks for taking that into account.

I was looking at the code and I can see some choices have been made either in metadata-action or in semver that made it a bit difficult to add prerelease and build values with handlebars. I was looking into ways to make those available with helpers, here is what I came up with (there's still an issue on the type of the entry data, register might happen at the wrong time)

    handlebars.registerHelper("prereleaseMetadata", function () {
      return (this.prerelease ? "-" + this.prerelease.join(".") : "");
    });
    
    handlebars.registerHelper("buildMetadata", function () {
      return (this.build ? "+" + this.build.join(".") : "");
    });
    
    handlebars.registerHelper("completeVersion", function () {
      return (
        [this.major, this.minor, this.patch].join(".") +
        (this.prerelease ? "-" + this.prerelease.join(".") : "") +
        (this.build ? "+" + this.build.join(".") : "")
      );
    });

I put the changes in a branch, but I'm still working on adding a handlebar environment around that. https://github.com/Murazaki/metadata-action/tree/feature/semver-supplementary-data

Murazaki avatar Feb 13 '24 09:02 Murazaki