Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mu88 opened this issue Nov 18, 2023 · 4 comments
Open

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

mu88 opened this issue Nov 18, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@mu88
Copy link

mu88 commented Nov 18, 2023

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
Copy link
Contributor

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

@cabauman cabauman added the enhancement New feature or request label Nov 18, 2023
@mu88
Copy link
Author

mu88 commented Nov 19, 2023

that would be awesome!

@mu88
Copy link
Author

mu88 commented Nov 26, 2023

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
Copy link
Contributor

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants