versionize / versionize

Automatic versioning and CHANGELOG generation, with semver and conventional commits for dotnet
MIT License
298 stars 46 forks source link

feature request: control naming of version tag (omit ' v' prefix) #110

Open mu88 opened 11 months ago

mu88 commented 11 months ago

Hi 👋🏻

First of all, thank you for your amazing project! I added it yesterday to a couple of my projects and it works very well 👏🏻

One thing that I stumbled upon was using the Git tag created by versionize as Docker image tag and the tag's v prefix. For example, let's assume calling dotnet versionize creates a new Git tag v3.0.0. Now when creating a Docker image for this release via GitHub Actions, I have to shorten the Git tag like this so that my final image is tagged mu88/raspifancontroller:3.0.0 instead of mu88/raspifancontroller:v3.0.0 (which would happen when using ${{ github.ref_name }}):

    - name: Write release version
      run: |
        VERSION=${GITHUB_REF_NAME#v}
        echo Version: $VERSION
        echo "VERSION=$VERSION" >> $GITHUB_ENV
    - name: Build Docker and Push
      run: dotnet publish RaspiFanController/RaspiFanController.csproj --os linux --arch arm64 /t:PublishContainer '-p:ContainerImageTags="${{ env.VERSION }};latest"'

Since I had to insert this snippet into each of my Release pipeline, it would be cool if I could instruct versionize to create a Git tag without the v prefix (i. e. 3.0.0 instead of v3.0.0).

cabauman commented 11 months ago

Hello, @mu88! Yeah, that's a reasonable feature that most versioning libraries have. We'll look into getting that included.

mu88 commented 11 months ago

that would be awesome!

mu88 commented 11 months ago

Hi @cabauman

I have looked around a bit in the code and two ideas came to my mind:

  1. Introduce public bool OmitTagPrexifx { get; set } in VersionizeOptions (which just signals to omit the version prefix v and is false by default to not break with previous behavior) and check for this property in WorkingCopy.Versionize. This is (probably/hopefully 🤞🏻) easy to implement, but further complicates the logic of WorkingCopy.Versionize.
  2. Hook into the string formatting, which is more work and probably an overkill:
    1. Introduce both public string VersionString { get; set } in VersionizeOptions and extension method public static string ToVersionizeString(this NuGet.Versioning.SemanticVersion version) which consumes VersionizeOptions.VersionString.
    2. Implement a custom IFormatProvider and pass it here.
cabauman commented 11 months ago

Thanks for the ideas. I'm about to head out of country for a couple weeks, so it'll take some time to get around to this, but we'll get there :)

mu88 commented 5 months ago

Hi @cabauman - I hope this reaches you well 🙂 is there any news about this issue?

cabauman commented 5 months ago

Hello! Oops, sorry. Thanks for reminding me.

EdHPOS commented 3 months ago

This sounds interesting! Is there a feature road map at all for enhancements to this package?

cabauman commented 1 month ago

I'll come back to this issue after v2 is released (soon).