jincod / dotnetcore-buildpack

Heroku .NET Core Buildpack
MIT License
751 stars 365 forks source link

Using git tag for assembly version #166

Closed stewie1570 closed 2 years ago

stewie1570 commented 2 years ago

Hello,

I've got a humble suggestion. Firstly, Thank You for creating this buildpack. It's awesome!!

I was going to try to do this myself and then offer up a PR but I can't figure out how to get it to work. I'm trying to suffix the dotnet publish command with /p:AssemblyVersion=${GIT_TAG} /p:Version=${GIT_TAG} but I can't figure out how to get the GIT_TAG.

Is this possible? If so, would it be possible to only suffix the /p's when the Git tag is available so it doesn't mess up anyone not using Git or tags?

jincod commented 2 years ago

Hello @stewie1570

It's nice to hear

I'm not sure about GIT_TAG, but have you tried SOURCE_VERSION? Docs: https://devcenter.heroku.com/articles/buildpack-api#bin-compile

stewie1570 commented 2 years ago

Looks like that will be a hash of the latest git commit. I'm assuming it's the same hash displayed in the dashboard. That is very useful too.

I really like semver. I wonder if '$GIT_TAG-$SOUCE_VERSION' (v1.2.3-hash) would be possible. If that is not possible (or not preferred) then yes, I'll use SOURCE_VERSION. Thank you for that! I didn't know about it.