-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgitversion.yml
43 lines (35 loc) · 2 KB
/
gitversion.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Runs GitVersion to determine the SemVer for the build based on git commit history.
# This version is then stashed in pipeline variable 'gitversion' which may then be
# referenced in subsequent pipeline steps as $(gitversion).
#
# This version is also used to set the label for the Azure DevOps pipeline run.
#
# NOTE:
# This template expects and requires that GitVersion is installed on the build
# machine (https://github.com/GitTools/GitVersion)
#
# Install on Windows using chocolatey: choco install GitVersion.Portable
#
# The Git command-line client is also required (not by GitVersion itself but due
# the need to run Git commands to sync tags).
steps:
- powershell: |
# First make sure that local tags reflect remote tags (otherwise any which were
# deleted in the remote will still be in the local repo). The two commands that
# follow first delete ALL local tags then fetch tags from the remote)
git tag -l | %{git tag -d $_}
git fetch --tags
# Now we can run GitVersion, confident that any tag-based versioning will reflect
# the tags in the repo.
$GitVersion = GitVersion | ConvertFrom-Json
# Set output variables. To consume these in subsequent steps map the output
# variables as job variables for those jobs
Write-Host "##vso[task.setvariable variable=Major;isOutput=true]$($GitVersion.Major)"
Write-Host "##vso[task.setvariable variable=Minor;isOutput=true]$($GitVersion.Minor)"
Write-Host "##vso[task.setvariable variable=Patch;isOutput=true]$($GitVersion.Patch)"
Write-Host "##vso[task.setvariable variable=PreReleaseLabel;isOutput=true]$($GitVersion.PreReleaseLabel)"
Write-Host "##vso[task.setvariable variable=PreReleaseNumber;isOutput=true]$($GitVersion.PreReleaseNumber)"
Write-Host "##vso[task.setvariable variable=SemVer;isOutput=true]$($GitVersion.SemVer)"
Write-Host "##vso[build.updatebuildnumber]$($GitVersion.SemVer)"
name: GitVersion
displayName: GitVersion