0
votes

I already have an existing Azure DevOps pipeline. It gets triggered whenever a new commit is pushed to the corresponding GitHub repo and does all the ceremony (build, test, etc.).

Now I want to setup the release. A release has to happen whenever a pushed commit is tagged with release-v*. This should execute the same ceremony as already specified, but finally does a GitHub release.

What is the best way to accomplish this? Do I need to duplicate my pipeline? Can I reuse it?

1
help.github.com/en/categories/… Probably wait till November.Lex Li

1 Answers

0
votes

I finally ended up with the following build configuration:

trigger:
- master
- release

# All the other YAML stuff

- task: PublishGitHubRelease@0
  inputs:
    applicationName: 'TheApplication'
    gitSourceOption: 'github'
    token: '$(GitHubPAT)'
    repo: 'TheRepository'
    owner: 'TheOwner'
    tagName: 'v$(build.buildNumber)'
    releaseName: 'v$(build.buildNumber)'
    draft: false
    prerelease: false
    assetsPattern: '$(Build.SourcesDirectory)/*'
  displayName: 'Create GitHub release'
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/release'))

Now I'm having two different branches: master and release. The build configuration gets triggered for both branches, but the final task PublishGitHubRelease will only be executed for the release branch. The very last line condition: is responsible for that. For a release, I'm doing a fast-forward merge from master to release.

It's not my favorite solution, but it's okay for now.