-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
285 lines (258 loc) · 9.84 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: $(GITVERSION_FullSemVer)
trigger:
- "master"
- "hotfix/*"
- "release/*"
- "develop"
- "feature/*"
pr:
- "master"
- "develop"
pool:
vmImage: windows-latest
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
System.Debug: ${{ eq(variables['Build.SourceBranchName'], 'azure-pipelines') }}
${{ if eq(variables['Build.SourceBranchName'], 'azure-pipelines') }}:
verbosity: -v:diag
${{ if ne(variables['Build.SourceBranchName'], 'azure-pipelines') }}:
verbosity: ""
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
branch: master
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/hotfix/') }}:
branch: hotfix
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') }}:
branch: release
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/develop') }}:
branch: develop
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/') }}:
branch: feature
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
branch: pull-request
stages:
- stage: ci
displayName: Continuous integration
variables:
BuildConfiguration: "Release"
NuGet.Packages: $(Pipeline.Workspace)/.nuget/packages
jobs:
- job: build
displayName: Build
steps:
- checkout: self
displayName: "Checkout $(Build.SourceBranch)"
submodules: true
- task: UseDotNet@2
inputs:
useGlobalJson: true
performMultiLevelLookup: true
displayName: "Install .Net SDK"
- task: UseDotNet@2
inputs:
version: 2.1.x
packageType: runtime
performMultiLevelLookup: true
displayName: "Install .Net Core 2.1.x Runtime"
- task: UseDotNet@2
inputs:
version: 3.1.x
packageType: runtime
performMultiLevelLookup: true
displayName: "Install .Net Core 3.1.x Runtime"
- task: gitversion/setup@0
inputs:
versionSpec: '5.3.5'
displayName: Install GitVersion
- task: Cache@2
inputs:
key: 'nuget | "$(Agent.OS)" | **/packages.lock.json,!**/bin/**'
restoreKeys: |
nuget | "$(Agent.OS)"
path: $(NuGet.Packages)
displayName: Cache NuGet packages
- task: gitversion/execute@0
inputs:
updateAssemblyInfo: true
updateAssemblyInfoFilename: $(Build.SourcesDirectory)/src/SolutionInfo.cs
displayName: Use GitVersion
- task: DotNetCoreCLI@2
inputs:
command: restore
projects: |
src/**/*.csproj
test/**/*.csproj
docfx/**/*.proj
feedsToUse: config
nugetConfigPath: nuget.config
displayName: "dotnet restore"
- task: DotNetCoreCLI@2
inputs:
command: build
projects: "src/**/*.csproj"
arguments: "--configuration $(BuildConfiguration) --no-restore $(verbosity)"
displayName: "dotnet build"
- task: DotNetCoreCLI@2
inputs:
command: test
projects: "test/**/*.UnitTests/*.csproj"
arguments: "--configuration $(BuildConfiguration) --no-restore"
displayName: "dotnet test"
- task: DotNetCoreCLI@2
inputs:
command: pack
packagesToPack: "src/**/*.csproj"
configurationToPack: "$(BuildConfiguration)"
packDirectory: "$(Build.ArtifactStagingDirectory)/packages"
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: 'GitVersion.NuGetVersion'
displayName: "dotnet pack release"
- publish: "$(Build.ArtifactStagingDirectory)/packages"
artifact: packages
displayName: "Publish Artifact: packages"
- task: DotNetCoreCLI@2
env:
DOCFX_SOURCE_BRANCH_NAME: "$(Build.SourceBranchName)"
inputs:
command: build
projects: "docfx/**/*.proj"
arguments: "--configuration $(BuildConfiguration)"
displayName: "docfx build"
- task: CopyFiles@2
inputs:
SourceFolder: $(Build.SourcesDirectory)/docfx/_site
TargetFolder: $(Build.ArtifactStagingDirectory)/docfx
CleanTargetFolder: true
displayName: "Copy To Artifact: docfx"
- publish: "$(Build.ArtifactStagingDirectory)/docfx"
artifact: docfx
displayName: "Publish Artifact: docfx"
- script: |
echo ##vso[task.setvariable variable=SemVer;isOutput=true]$(semVer)
echo ##vso[task.setvariable variable=AssemblySemVer;isOutput=true]$(assemblySemVer)
echo ##vso[task.setvariable variable=AssemblySemFileVer;isOutput=true]$(assemblySemFileVer)
echo ##vso[task.setvariable variable=InformationalVersion;isOutput=true]$(informationalVersion)
echo ##vso[task.setvariable variable=NuGetVersion;isOutput=true]$(nuGetVersion)
name: GitVersion
displayName: GitVersion Output Variables
- stage: publish
displayName: Publish
dependsOn: ci
condition: and(succeeded(), in(variables.branch, 'develop', 'release', 'hotfix', 'master'))
jobs:
- deployment: ci
displayName: CI
environment: myget
strategy:
runOnce:
deploy:
steps:
- checkout: none
- download: current
artifact: packages
- task: NuGetCommand@2
name: push
inputs:
command: push
packagesToPush: "$(Pipeline.Workspace)/packages/**/*.nupkg"
nuGetFeedType: external
publishFeedCredentials: "MyGet - ExpressionTreeToolkit"
displayName: "MyGet push"
- deployment: nuget
displayName: NuGet
environment: nuget
condition: and(succeeded(), in(variables.branch, 'release', 'hotfix', 'master'))
strategy:
runOnce:
deploy:
steps:
- checkout: none
- download: current
artifact: packages
- task: NuGetCommand@2
name: nuget
inputs:
command: push
packagesToPush: "$(Pipeline.Workspace)/packages/**/*.nupkg"
nuGetFeedType: external
publishFeedCredentials: "NuGet - ExpressionTreeToolkit"
displayName: "NuGet push"
- deployment: ghpages
displayName: GitHub Pages
environment: gh-pages
condition: and(succeeded(), in(variables.branch, 'master'))
variables:
GitHub.UserName: "Alessio Gogna"
GitHub.UserEmail: "[email protected]"
Version.Tag: $[ format('v{0}', stageDependencies.ci.build.outputs['GitVersion.SemVer']) ]
strategy:
runOnce:
deploy:
steps:
- checkout: self
clean: true
persistCredentials: true
path: gh-pages
- download: current
artifact: docfx
- script: |
git checkout --progress --no-recurse-submodules -f gh-pages
git rm -rf .
workingDirectory: $(Pipeline.Workspace)/gh-pages
displayName: "Checkout gh-pages & Clean"
- task: CopyFiles@2
inputs:
SourceFolder: "$(Pipeline.Workspace)/docfx"
TargetFolder: "$(Pipeline.Workspace)/gh-pages"
displayName: "Copy Files from docfx to $(Pipeline.Workspace)/gh-pages"
- script: |
git add -v .
git -c user.name="$(GitHub.UserName)" -c user.email="$(GitHub.UserEmail)" commit -a -v -m "$(Version.Tag)"
git tag $(Version.Tag)
git push -v --tags origin gh-pages
workingDirectory: $(Pipeline.Workspace)/gh-pages
displayName: "Add & Commit & Push gh-pages"
- stage: release
displayName: Release
dependsOn:
- ci
- publish
jobs:
- job: github
displayName: GitHub
variables:
Version.Tag: $[ format('v{0}', stageDependencies.ci.build.outputs['GitVersion.SemVer']) ]
steps:
- checkout: none
- download: none
- task: GitHubRelease@1
name: githubrelease
inputs:
action: edit
gitHubConnection: "GitHub connection"
tagSource: userSpecifiedTag
tag: $(Version.Tag)
isPreRelease: ${{ ne(variables.branch, 'master') }}
isDraft: ${{ notIn(variables.branch, 'release', 'hotfix', 'master') }}
assetUploadMode: delete
assets: |
$(Pipeline.Workspace)/packages/**/*.nupkg
$(Pipeline.Workspace)/packages/**/*.snupkg
displayName: Create GitHub Release
- ${{ if eq(variables['System.Debug'],'true') }}:
- stage: debug
displayName: Debug
dependsOn:
- ci
- publish
- release
condition: always()
jobs:
- job:
variables:
Version.Tag: $[ format('v{0}', stageDependencies.ci.build.outputs['GitVersion.semVer']) ]
steps:
- checkout: none
- script: echo $(Version.Tag)
displayName: Dump Variables