James Montemagno
James Montemagno

Live, Love, Bike, and Code.

Live, Love, Bike, and Code

Share


Tags


Super Simple Git Tagging & Releases in Azure DevOps

I am going to be honest with all of you, I never really understood Git tags and releases inside of GitHub. In my old TFVC days I would just create a branch with the name of the release and call that my "tag" so I could always go back to it. What sparked my interest was seeing a bunch of popular projects that I was using combine tags with the GitHub releases. I started reading the documentation and still wasn't sold on it because I have a full CI/CD pipeline setup for all of my projects and I wasn't sure how this would fit in. Then the lightbulb went off when I saw Jon Dick implement an amazing tagging scheme that would fire off a build, compile a NuGet, and then release the artifacts to NuGet automatatically...

mindblown

Even though this was the coolest thing ever I didn't want to go changing all of my pipelines, but it did encourage me stop doing random branches for releases and streamline my tagging and releases when publishing NuGets. This is surprisingly easy to do with the new GitHub Release task. It is a very nice extension that allows you to create a tag, or re-use a tag, add a changelog file, specify release name, add artifacts, and a bunch more.

In my continuous delivery pipeline I have the following workflow:

Pipeline

My strategy here is to ensure that when I go to NuGet (beta) I create a pre-release tag and release and then when I go to full production I simply update that existing release/tag with updated information.

Uploading a Changelog

Traditionally I never uploaded anything to the drop folder except for the NuGet packages, but a nice thing with the the release task is that you can attach a changelog file (or manually enter it). Since I have a changelog file checked in to each of my repositories that I regularly update, I can just add it to the drop folder in my CI pipeline. In the Copy Files task I simply added:

**\bin\$(BuildConfiguration)\**
**\CHANGELOG.md

Adding a Pre-Release Tag & Release

After I release my pre-release package to NuGet, I want to create my very first Tag and Release. First step is to simply add the GitHub Release task:

Task

Now, it is time to fill in the information for the tag and release:

$(System.DefaultWorkingDirectory)/**/drop/beta-public/*.nupkg

Editing a Release

Now, when I go into my final phase to publish my packages to stable on NuGet I want to modify the release I just created. You could optionally create a new release and different tag, but this makes no sense to me currently (leave comments below to let me know what you think).

You can simply add the same exact Task and instead of specifying Create for the Action specify Edit. You will fill in all of the same information except at the end:

And just like that you will have beautiful releases automatically when you publich to NuGet in pre-release or stable:

Capture

Copyright © James Montemagno 2019 All rights reserved. Privacy Policy

View Comments