Automating Releases in GitHub through Azure Pipelines

Raiyan Alam

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:

steps:
– task: GithubRelease@0
  displayName: ‘Create GitHub Release’
  inputs:
   githubConnection: zenithworks
   repositoryName: zenithworks/simplehtml

You can also use the Visual Editor if you prefer.

Actions:

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:

steps:
– task: GitHubRelease@0
  displayName: ‘Edit GitHub Release’
  inputs: gitHubConnection: zenithworks
  repositoryName: zenithworks/simplehtml
  action: edit
  tag: $(draftReleaseTag)
  assets: $(Build.ArtifactStagingDirectory)/distributableBinaries/* 

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.

Resources:

  1. Task code in GitHub
  2. YAML syntax and documentation

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • Érico P 0

    I need the Github Release to do the following:
    -> When I create a Release on Github, which also creates a tag, this should be listened by Azure Pipelines, to trigger a build (currently this isn’t true, one needs to manually queue a job!!!!!)
    -> After that, I need Azure Pipelines to KNOW which tag was pushed, and go into this tag and upload the produced assets
    –>> Currently the ‘create’ action is useless if you are building multiplatform, you need to figure out which build will finish first to be allowed to create a release, otherwise it will fail. So this leaves only ‘edit’action. But for ‘edit’ action, you need to before create a script, to figure out the tag, and save that Tag to an environment variable, so you can tell which Tag to edit.
    Travis, CircleCI and AppVeyor currently all have more sane defaults for their same task.

  • Allen Tsui 0

    It seems that not possible to do that currently.

    Create: Pull code using devops, build, and create a release.

    1 CI on release is not possible.
    When creating a release using artifact from Github, the CI cannot be enabled, displaying: Resource not accessible by integration.
    https://developercommunity.visualstudio.com/content/problem/896437/github-could-not-create-service-hooks-subscription.html

    2 Don’t know what the designed way to specify the “target” field on Github Release Task.

    Edit: Pull the source code from a new draft release, build, and edit the release removing the draft mark and uploading the built packages.

    1 No way found to download the source related to the new created draft release. The source file package in the draft release is not downloaded by Download Github Release task.

    2 Don’t know what release should be edit.

Feedback usabilla icon