Loading...
Creating GitHub release using Azure DevOps pipeline

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

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.

  1. Navigate to the Azure DevOps project
  2. Navigate to pipelines - releases
  3. Click an existing pipeline or create a new one.
  4. Click an existing stage or add a new one.
  5. Click add new step
  6. Find 'GitHub Release' Screenshot of Add new step with 'GitHub Release'
  7. Provide the following properties:
    • GitHub Connection
    • GitHub repository screenshot of GitHub connection and repository properties
  8. 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. Screenshot of GitHub action
  9. Define the value of the tag
    • Use $(Build.BuildNumber) to use the version number used in the build.
  10. 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)
  11. Add assets, if you wish to attach the build output.
  12. 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.

Yaml Example:

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. Screenshot of GitHub release of Kenc.ACMELib

When looking at the Git history of the branch, the version tag have been added to the targeted commit. Screenshot of Git log showing the version tag was added on the target commit

There are 0 comments

Add your comment