Creating GitHub release using Azure DevOps pipeline
GitHub is pretty much the defacto-standard for hosting source code for Open Source projects. While it excels at hosting Source Code, it lacks automated builds and as such requires integration with systems like Azure DevOps, Jenkins or similar.
For most of my projects, I do my builds using Azure DevOps and while Azure DevOps pushes updated nuget packages to nuget.org, I wanted to configure it to create releases on GitHub as well with the binaries produced.
GitHub releases are defined by a Git tag and release metadata (+ binaries). When creating a release, you can manually create a tag in your source tree using 'Git tag' and create the releases using the GitHub releases page.
Configuring the release pipeline
I didn't want the releases to be created during each build, but rather for each release I decide to publish, however these steps can also be used in a build pipeline.
- Navigate to the Azure DevOps project
- Navigate to pipelines - releases
- Click an existing pipeline or create a new one.
- Click an existing stage or add a new one.
- Click add new step
- Find 'GitHub Release'
Provide the following properties:
- GitHub Connection
- GitHub repository
Decide on the strategy you want to go for - either versioning each release or using custom tags.
- Use "Create" action if you are versioning each release
- Use "Edit" if you have an existing tag, you wish to update to the build commit.
- The Target specifies the commit the tag is associated with. When using GitHub with Azure DevOps $(Build.SourceVersion) contains the commit id. See Microsoft docs, Predefined variables for a list of variables.
Define the value of the tag
- Use $(Build.BuildNumber) to use the version number used in the build.
Define the release title, the title is shown in the header on GitHub releases page.
- Note, by default it is using $(Build.BuildNumber) - $(Build.SourceVersionMessage)
- Add assets, if you wish to attach the build output.
- Check "Add Changelog" if you want to generate an automated changelog, based on issues resolved by each commit in the release.
save and run the release.
steps: - task: GitHubRelease@1 displayName: 'GitHub release (create)' inputs: gitHubConnection: ACME.Github tagSource: userSpecifiedTag tag: '$(Build.BuildNumber)' title: '$(Build.BuildNumber)' assets: '**/*.nupkg' changeLogCompareToRelease: lastNonDraftRelease
GitHub release example
The Yaml configuration seen above, was used to create releases for Kenc.ACMELib on GitHub.
When looking at the Git history of the branch, the version tag have been added to the targeted commit.