Skip to content

Instantly share code, notes, and snippets.

@DaveRuijter
Created October 3, 2021 19:47
Show Gist options
  • Select an option

  • Save DaveRuijter/c72cecb255cd52d73aeae0f67cd0ee1e to your computer and use it in GitHub Desktop.

Select an option

Save DaveRuijter/c72cecb255cd52d73aeae0f67cd0ee1e to your computer and use it in GitHub Desktop.
Azure DevOps YAML pipeline for release administration, with automatic SemVer based on GitVersion and automatic release notes publication
trigger:
- main
- master
pool:
vmImage: ubuntu-latest
## Job to create release and add tag
jobs:
- job: CalculateVersion
displayName: Tagging release version
steps:
# Checkout with persist credentials
- checkout: self
persistCredentials: true
# Install GitVersion
- task: gitversion/setup@0
displayName: Install GitVersion
inputs:
versionSpec: "5.x"
# Determine the semantic version
- task: gitversion/execute@0
displayName: Calculating version
inputs:
useConfigFile: True
configFilePath: ".azuredevops/gitversion.yml"
# Update Build.BuildNumber to use SemVer, as by default it uses FullSemVer
- pwsh: |
Write-Host "##vso[build.updatebuildnumber]$(GitVersion.SemVer)"
displayName: Update Build.BuildNumber
# Adds the tag for the calculated semantic version
- task: PowerShell@2
displayName: Adding git release tag
inputs:
targetType: inline
script: |
Write-Host "Configuring git author info.." -ForegroundColor Cyan
git config user.email "Azure DevOps pipeline"
git config user.name "Azure.Devops@pipeline.com"
Write-Host "Adding git tag for release $(GitVersion.SemVer).." -ForegroundColor Cyan
git tag -a $("v$(GitVersion.SemVer)") -m $("Release $(GitVersion.SemVer)")
Write-Host "Doing git push.." -ForegroundColor Cyan
git push --tags
Write-Host "Done." -ForegroundColor Cyan
## Job to create release notes file and publish it to the wiki
- job: CreateReleaseNotes
displayName: Creating release notes
dependsOn: CalculateVersion
steps:
# Generates a release notes file
- task: XplatGenerateReleaseNotes@3
displayName: "Generate release notes"
inputs:
outputfile: '$(System.DefaultWorkingDirectory)\releasenotes.md'
templateLocation: File
templatefile: ".azuredevops/release-notes-template.md"
dumpPayloadToConsole: false
dumpPayloadToFile: false
replaceFile: True
getParentsAndChildren: False
getAllParents: False
getIndirectPullRequests: False
stopOnError: True
considerPartiallySuccessfulReleases: False
# Publishes the release notes in the project wiki
- task: WikiUpdaterTask@1
displayName: "Publish to the wiki"
inputs:
repo: "https://dev.azure.com/devruijter/playground/_git/playground.wiki" #REPLACE THIS!! NB. use _git instead of _wiki/wikis in the uri
filename: "Release-Notes.md" #Note: want a space in the name of the page? Use a '-' here!
replaceFile: false
appendToFile: false
dataIsFile: true
sourceFile: '$(System.DefaultWorkingDirectory)\releasenotes.md'
message: "Update from Pipeline"
gitname: $(Release.RequestedFor)
gitemail: $(Release.RequestedForEmail)
useAgentToken: true
localpath: '$(System.DefaultWorkingDirectory)\repo'
@byte-surgeon
Copy link

##[error]Error: GitVersion configuration file not found at /home/vsts/work/1/s/.azuredevops/gitversion.yml I'm a newbie, and I don't know what is wrong here?

You need to install the extension first from https://marketplace.visualstudio.com/items?itemName=gittools.gittools

@delpierro140
Copy link

delpierro140 commented Oct 13, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment