-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
106 lines (95 loc) · 2.79 KB
/
azure-pipelines.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: $(build.buildId)
variables:
buildConfiguration: 'Release'
version: '1.0.3'
buildNumber: $[counter('versioncounter', 70)]
trigger:
branches:
include:
- master
- refs/tags/v*
paths:
include:
- src/
- nuget/*.nuspec
pr:
branches:
include:
- master
paths:
include:
- src/
pool:
vmImage: vs2017-win2016
demands: msbuild
steps:
- powershell: |
$isVersionTag = $false
$isPR = $false
$versionTagPattern = "(tags\/v)(\d+\.\d+\.\d+)$"
$versionTagMatches = [regex]::matches($Env:BUILD_SOURCEBRANCH,$versionTagPattern)
$prPattern = "pull\/(\d+)\/"
$prMatches = [regex]::matches($Env:BUILD_SOURCEBRANCH,$prPattern)
switch($versionTagMatches.Count)
{
0
{
$isVersionTag = $false
}
default
{
$isVersionTag = $true
}
}
switch($prMatches.Count)
{
0
{
$isPR = $false
}
default
{
$isPR = $true
}
}
if ($isVersionTag -eq $true)
{
Write-Host "Building from tag..."
$versionFromTag = $versionTagMatches[0].Groups[2]
Write-Host "Setting version to $versionFromTag from tag name..."
Write-Host "##vso[task.setvariable variable=packageVersion]$versionFromTag"
Write-Host "##vso[task.setvariable variable=assemblyVersion]$versionFromTag"
}
elseif ($isPR -eq $true)
{
Write-Host "Building from PR commit..."
$prVersion = $Env:version + "-pr" + $prMatches[0].Groups[1] + "." + $Env:buildNumber
Write-Host "Setting version to $prVersion..."
Write-Host "##vso[task.setvariable variable=packageVersion]$prVersion"
Write-Host "##vso[task.setvariable variable=assemblyVersion]$version"
}
else
{
Write-Host "Building from master branch commit..."
$betaVersion = $Env:version + "-beta." + $Env:buildNumber
Write-Host "Setting version to $betaVersion..."
Write-Host "##vso[task.setvariable variable=packageVersion]$betaVersion"
Write-Host "##vso[task.setvariable variable=assemblyVersion]$version"
}
displayName: 'PowerShell script - Set version number'
- task: NuGetToolInstaller@0
- task: NuGetCommand@2
- task: MSBuild@1
inputs:
solution: 'src/*.sln'
configuration: '$(buildConfiguration)'
msbuildArguments: '/p:PackageVersion=$(packageVersion);AssemblyVersion=$(assemblyVersion);AssemblyFileVersion=$(assemblyVersion)'
- task: CopyFiles@2
displayName: 'Copy .nupkg to artifact staging directory'
inputs:
SourceFolder: '$(build.sourcesDirectory)'
Contents: '**\bin\$(buildConfiguration)\**\*.nupkg'
TargetFolder: '$(build.artifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(build.artifactStagingDirectory)'