Following on from my posts Continuous Delivery with Sitecore Part 1 – TeamCity Setup and Continuous Delivery with Sitecore Part 2 – Octopus Deploy Setup, I’ve added another step to achieve Semantic Versioning (SemVer) in my deployment pipeline, as we are already using GitFlow for branching we only had some configuration changes to make.
I’ve added GitVersion to our release process, they claim
Versioning when using git, solved. GitVersion looks at your git history and works out the semantic version (semver.org) of the commit being built.
This enables my release numbers to be automatically generated using semver.org and this number can be used to version assemblies, add source control tags and for any NuGet packages or other artifacts your build process generates.
Install-Package GitVersionTask -Version 3.6.3
I use Team City and Octopus Deploy for build and deployment currently but GitVersion Supports a wide range of build tools.
GitVersion has support for quite a few build servers out of the box. Currently we support:
Set the Build number format of your Team City Build to _%system.GitVersion.SemVer% _the placeholder we previously created.
Add a new Command Line step to your build, after your NuGet Packages have been restored and before your Build and OctoPack step. The Command Executable is GitVersion and the command parameters are ****. /updateAssemblyInfo /output buildserver****
Add the new system variable in the
On your Create Release and Develop Release steps when using the Octopus TeamCity plugin set the Release number field to **%system.GitVersion.NuGetVersion%**
That is all the setup required, when you next Run a new build on TeamCity you should see the results:-
TeamCity builds with SemVer build numbers.
TDS packages with NuGetVersion version generated by GitVersion
Octopus Deploy release numbers using NuGetVersion
Assemblies stamped with the same SemVer release number.