I needed a way to auto-tag my release when I’m modifying the AssemblyInfo.cs file in my C# application.

I created a pre-commit, post-commit and simple version.sh file to do so:

The version.sh contain which file need to be monitored. When this file is changed and part of the commit, the new version will be extracted. (please be sure you only have one

[assembly: AssemblyVersion("3.4.2.*")]

in your Assembly file). The version need to be specified as shown (X.X.X.X) where the last X is the build version (that I let Visual Studio manage and don’t consider relevant for a tag).

pre-commit

Check for version change, if it’s the case, change also the version the appveyor.yml file and add it to the commit.

post-commit

If the version change, add a new tag using the commit message and the version extracted from the AssemblyInfo.cs file.

 

Credits toĀ entrepreheroĀ for the image