-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
201 lines (180 loc) · 6.67 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: $(SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.r)
pool:
vmImage: 'windows-latest'
trigger:
tags:
include:
- v*
branches:
include:
- master
pr:
- master
jobs:
- job: BuildAndTest
displayName: 'Build and test'
steps:
- task: DotNetCoreCLI@2
displayName: 'Restore all'
inputs:
command: restore
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build all'
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration Release --no-restore'
- task: DotNetCoreCLI@2
displayName: 'Test'
condition: succeeded()
inputs:
command: 'test'
projects: '**/*.Tests/*.csproj'
arguments: '--configuration Release --no-build --collect "Code coverage"'
testRunTitle: 'Test all'
publishTestResults: true
- job: PublishArtifact
displayName: 'Package creation'
dependsOn: BuildAndTest
condition: succeeded()
variables:
lastOrCurrentVersionTag: ''
nightlyBuildVersion: 'unset'
${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/v') }}:
isReleaseTagBranch: true
steps:
- task: PowerShell@2
displayName: 'Get last tag version'
inputs:
targetType: 'inline'
script: |
Try {
$LastTag = git describe --tags
}
Catch { }
Finally {
if (!$LastTag) {
if ($env:isForRelease) {}
$LastTag = 'v0.0.0'
}
Write-Host "##vso[task.setvariable variable=lastOrCurrentVersionTag]$LastTag"
echo "Last branch tag is: $LastTag"
}
ignoreLASTEXITCODE: true
- task: PowerShell@2
displayName: 'Check tag version match'
condition: variables['isReleaseTagBranch']
env:
LastTag: $(lastOrCurrentVersionTag)
inputs:
targetType: 'inline'
errorActionPreference: 'silentlyContinue'
script: |
Try {
$ProjectTag = Get-ChildItem -Path . -Include *.csproj -Exclude *.*Tests*.csproj -Recurse |
Select-Xml -XPath "/Project/PropertyGroup/Version" |
Select-Object -Property @{Name="Version"; Expression={$_.Node.InnerXml}} |
Select-Object -ExpandProperty Version |
Select-Object -First 1
echo "Project file version definition is: $ProjectTag"
}
Catch {
Write-Host "##vso[task.LogIssue type=error;]No 'Version' defined in project's .csproj file"
Write-Host "##vso[task.complete result=Failed;]No project version"
}
$LastTag = $env:LastTag.TrimStart('v')
if ($ProjectTag -ne $LastTag) {
Write-Host "##vso[task.LogIssue type=error;]Project 'Version' property in .csproj does not match release tag version"
Write-Host "##vso[task.complete result=Failed;]Version does not match"
}
ignoreLASTEXITCODE: true
- task: PowerShell@2
displayName: 'Create nightly build version tag'
condition: not(variables['isReleaseTagBranch'])
env:
CurrentBuildID: $(Build.BuildNumber) # date is expanded at the top and then put in BuildNumber
LastTag: $(lastOrCurrentVersionTag)
inputs:
targetType: 'inline'
script: |
$LastTag = $env:LastTag.TrimStart('v')
$Suffix = $env:CurrentBuildID.Substring($env:CurrentBuildID.LastIndexOf('-'))
$NightlyBuildVersion = $LastTag + $Suffix
Write-Host "##vso[task.setvariable variable=nightlyBuildVersion]$NightlyBuildVersion"
echo "Nightly build version is: $ProjectTag"
ignoreLASTEXITCODE: true
- task: DotNetCoreCLI@2
displayName: 'Pack nightly build'
condition: not(variables['isReleaseTagBranch'])
inputs:
command: 'pack'
packagesToPack: '**/*.csproj;!**/*.Tests*.csproj'
includesymbols: true
includesource: true
configuration: 'Release'
versioningScheme: byEnvVar
versionEnvVar: nightlyBuildVersion
verbosityRestore: Minimal
verbosityPack: Normal
- task: PowerShell@2
displayName: 'Get and write nightly changelog diff'
condition: not(variables['isReleaseTagBranch'])
inputs:
filePath: 'getchangelogdiff.ps1'
arguments: '-TagVersion Unreleased -ChangeLogFilePath CHANGELOG.md -ChangeLogDiffWritePath $(Build.ArtifactStagingDirectory)\ChangeLogDiff.md'
- task: DotNetCoreCLI@2
displayName: 'Pack new release'
condition: variables['isReleaseTagBranch']
inputs:
command: 'pack'
packagesToPack: '**/*.csproj;!**/*.Tests*.csproj'
configuration: 'Release'
verbosityRestore: Minimal
verbosityPack: Normal
- task: PowerShell@2
displayName: 'Get and write release changelog diff'
condition: variables['isReleaseTagBranch']
inputs:
filePath: 'getchangelogdiff.ps1'
arguments: '-TagVersion $(lastOrCurrentVersionTag) -ChangeLogFilePath CHANGELOG.md -ChangeLogDiffWritePath $(Build.ArtifactStagingDirectory)\ChangeLogDiff.md'
- task: CopyFiles@2
displayName: 'Prepare files to archive'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**'
TargetFolder: '$(Agent.BuildDirectory)\ExtendedWPFVisualTreeHelper'
CleanTargetFolder: true
OverWrite: true
- task: DeleteFiles@1
displayName: 'Delete git history from archive'
inputs:
SourceFolder: '$(Agent.BuildDirectory)/ExtendedWPFVisualTreeHelper'
Contents: '.git'
- task: ArchiveFiles@2
displayName: 'Archive source as .zip'
inputs:
rootFolderOrFile: '$(Agent.BuildDirectory)/ExtendedWPFVisualTreeHelper'
includeRootFolder: true
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/source.zip'
replaceExistingArchive: true
- task: ArchiveFiles@2
displayName: 'Archive source as .tar.gz'
inputs:
rootFolderOrFile: '$(Agent.BuildDirectory)/ExtendedWPFVisualTreeHelper'
includeRootFolder: true
archiveType: 'tar'
tarCompression: 'gz'
archiveFile: '$(Build.ArtifactStagingDirectory)/source.tar.gz'
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
displayName: 'Publish package and archive'
condition: succeeded()
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
publishLocation: Container
${{ if variables['isReleaseTagBranch'] }}:
ArtifactName: 'prod'
${{ if not(variables['isReleaseTagBranch']) }}:
ArtifactName: 'dev'