Automating Releases in GitHub through Azure Pipelines
Do you own a GitHub repository? Do you create releases on GitHub to distribute software packages? Do you manually compile a list of changes to be included in release notes? If yes, you will be excited to know that you can now automate creation and modification of GitHub Releases directly from Azure Pipelines. This can be done through the GitHub Release task that is now rolled out to all users.
Here is a simple YAML syntax of the task for you to get started:
– task: GithubRelease@0
displayName: ‘Create GitHub Release’
You can also use the Visual Editor if you prefer.
There are 3 actions possible using this task:
- Create a GitHub Release
- Edit a GitHub Release
- Delete a GitHub Release
Create a GitHub release: This action is useful when you want to create a new release using the assets generated from successful CI builds. You can do it for all CI runs or only for specific ones. By default, the task will create a release only when a tag is found associated with the commit for which the CI is triggered. A common way to use this task would be to include it as the last step of your CI pipeline. At the end of each pipeline run, this task will check if a tag exists for the triggering commit, if yes then a release will be created in the GitHub repository by uploading the current built binaries as assets and appending changelog to release notes.
You can further restrict the release creation only to certain tag patterns. For this use custom condition in task control options and specify the required tag pattern. This task will then run only when it finds the matching tag.
Edit a GitHub release: This action is useful especially in cases where you continuously want to update an existing draft release with the latest built assets. With each CI run this task can edit the draft release (identified by tag) and upload latest build assets, release notes etc.
Here is a sample YAML that edits a release:
– task: GitHubRelease@0
displayName: ‘Edit GitHub Release’
inputs: gitHubConnection: zenithworks
This action can also be used in conjunction with approvals. A draft release can be automatically published publicly once the release notes and assets have been verified manually by 1 or multiple stakeholders and approved.
Discard a GitHub release: This action can be used to clean up older releases specifically the draft ones. This action deletes all releases matching the specified tag.
Compiling Release Notes:
Another exciting feature included in this task is the ability to automatically compile changelog. This task can automatically compute the changes that were done in this release compared to the last published release and append them to the release notes. The list of changes include the commit SHA, message and linked issues.
We are excited to have rolled out this feature and want to hear your feedback. Also, all of our built-in tasks, including GitHub release, are open source and available on GitHub for anyone to contribute. If you find any bugs or have any suggestions please feel free to report it there.