This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 471
/
azure-pipelines.yml
394 lines (346 loc) · 15 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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# See available software and versions on hosted agents here: https://docs.microsoft.com/azure/devops/pipelines/agents/hosted
variables:
CurrentSemanticVersionBase: '2.1.0'
PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)]
CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)'
NugetPackageVersion: '$(CurrentSemanticVersion)'
#MONO_VERSION: 6_4_0
#XCODE_VERSION: 11.4
NETCORE_VERSION: '6.0.x'
NETCORE_TEST_VERSION_3_1: '3.1.x'
NETCORE_TEST_VERSION_2_1: '2.1.x'
RunPoliCheck: 'false'
PathToMarkupCsproj: 'src/Markup/Xamarin.CommunityToolkit.Markup/Xamarin.CommunityToolkit.Markup.csproj'
PathToCommunityToolkitCsproj: 'src/CommunityToolkit/Xamarin.CommunityToolkit/Xamarin.CommunityToolkit.csproj'
PathToMauiCompatMarkupCsproj: 'src/Markup/Xamarin.CommunityToolkit.Markup.MauiCompat/Xamarin.CommunityToolkit.Markup.MauiCompat.csproj'
PathToMauiCompatCommunityToolkitCsproj: 'src/CommunityToolkit/Xamarin.CommunityToolkit.MauiCompat/Xamarin.CommunityToolkit.MauiCompat.csproj'
PathToSamplesSln: 'samples/XCT.Sample.sln'
PathToCommunityToolkitUnitTestCsproj: 'src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/Xamarin.CommunityToolkit.UnitTests.csproj'
PathToMarkupUnitTestCsproj: 'src/Markup/Xamarin.CommunityToolkit.Markup.UnitTests/Xamarin.CommunityToolkit.Markup.UnitTests.csproj'
Codeql.Enabled: true
resources:
repositories:
- repository: internal-templates
type: github
name: xamarin/yaml-templates
endpoint: xamarin
ref: refs/heads/main
trigger:
branches:
include:
- main
- develop
tags:
include:
- '*'
paths:
exclude:
- README.md
pr:
autoCancel: true
branches:
include:
- main
- develop
paths:
exclude:
- README.md
schedules:
- cron: "0 0 * * *"
displayName: Daily midnight build
branches:
include:
- main
jobs:
- job: build_windows_samples
displayName: Build Windows Samples
pool:
vmImage: windows-2019
steps:
- task: MSBuild@1
displayName: Build Solution
inputs:
solution: $(PathToSamplesSln)
configuration: Release
msbuildArguments: '/restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- job: build_windows
displayName: Build Windows Library
pool:
vmImage: windows-2019
steps:
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: $(NETCORE_VERSION)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Install .NET 3.1 Test SDK'
inputs:
version: $(NETCORE_TEST_VERSION_3_1)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Install .NET 2.1 Test SDK'
inputs:
version: $(NETCORE_TEST_VERSION_2_1)
includePreviewVersions: false
# if this is a tagged build, then update the version number
- powershell: |
$buildSourceBranch = "$(Build.SourceBranch)"
$tagVersion = $buildSourceBranch.Substring($buildSourceBranch.LastIndexOf("/") + 1)
Write-Host("Branch = $buildSourceBranch, Version = $tagVersion");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$tagVersion")
displayName: Set NuGet Version to Tag Number
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
# if this is a PR build, then update the version number
- powershell: |
$prNumber = $env:System_PullRequest_PullRequestNumber
$commitId = "$($env:System_PullRequest_SourceCommitId)".Substring(0, 7)
$fullVersionString = "$(CurrentSemanticVersionBase)-build-$(Build.BuildId).$prNumber+$commitId"
Write-Host("GitHub PR = $prNumber, Commit = $commitId");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$fullVersionString")
Write-Host "##vso[build.updatebuildnumber]$fullVersionString"
displayName: Set NuGet Version to PR Version
condition: and(succeeded(), eq(variables['build.reason'], 'PullRequest'))
# restore, build and pack the packages
- task: MSBuild@1
displayName: Build Xamarin.CommunityToolkit.csproj
inputs:
solution: $(PathToCommunityToolkitCsproj)
configuration: Release
msbuildArguments: '/restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- task: CopyFiles@2
inputs:
Contents: 'SignList.xml'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: MSBuild@1
displayName: Pack Community Toolkit NuGets
inputs:
solution: $(PathToCommunityToolkitCsproj)
configuration: Release
msbuildArguments: '/t:Pack /p:PackageVersion=$(NugetPackageVersion)'
- task: MSBuild@1
displayName: Build Markup Project
inputs:
solution: $(PathToMarkupCsproj)
configuration: Release
msbuildArguments: '/restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- task: MSBuild@1
displayName: Pack Markup NuGet
inputs:
solution: $(PathToMarkupCsproj)
configuration: Release
msbuildArguments: '/t:Pack /p:PackageVersion=$(NugetPackageVersion)'
- task: CmdLine@2
displayName: 'Run Markup Unit Tests'
inputs:
script: dotnet test $(PathToMarkupUnitTestCsproj) -c Release --collect "Code coverage" -p:BuildInParallel=false
- task: CmdLine@2
displayName: 'Run Community Toolkit Unit Tests'
inputs:
script: dotnet test $(PathToCommunityToolkitUnitTestCsproj) -c Release --collect "Code coverage" -p:BuildInParallel=false
# publish the packages
- task: PowerShell@2
displayName: 'Copy NuGet Packages to Staging Directory'
inputs:
targetType: 'inline'
script: |
$source = ".\src"
$filter = "nupkg"
Get-ChildItem -Path $source -Recurse | Where-Object { $_.Extension -match $filter } | Copy-Item -Destination "$(Build.ArtifactStagingDirectory)"
pwsh: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Unsigned NuGets'
inputs:
artifactName: nuget
pathToPublish: '$(Build.ArtifactStagingDirectory)'
# make sure we are following the rules, but only on the main build
- ${{ if eq(variables['System.TeamProject'], 'devdiv') }}:
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
displayName: Component Detection - Log
inputs:
scanType: LogOnly
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
displayName: Component Detection - Report
- task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@1
condition: eq(variables['RunPoliCheck'], 'true')
displayName: 'PoliCheck'
inputs:
targetType: F
- job: generate_mauicompat
displayName: Generate MauiCompat Library
pool:
vmImage: macos-latest
steps:
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: $(NETCORE_VERSION)
includePreviewVersions: false
- task: CmdLine@2
displayName: 'Install .NET MAUI Workload'
inputs:
script: 'dotnet workload install maui'
- task: JavaToolInstaller@0
displayName: 'Install Java SDK 11.0'
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- powershell: |
$mauiCompatExists = Test-Path -Path "$(PathToMauiCompatCommunityToolkitCsproj)"
Write-Output "##vso[task.setvariable variable=MauiCompatExists]$mauiCompatExists"
- task: CmdLine@2
displayName: 'Run MauiCompat Generator'
condition: eq (variables['MauiCompatExists'], False)
inputs:
script: 'zsh ./MauiCompat.sh'
- task: CopyFiles@2
displayName: 'Copy output'
inputs:
contents: '**'
targetFolder: '$(Build.ArtifactStagingDirectory)'
- publish: '$(Build.ArtifactStagingDirectory)'
displayName: 'Publish script'
artifact: drop
- job: build_mauicompat
dependsOn: generate_mauicompat
displayName: Build MauiCompat Library
pool:
vmImage: windows-latest
steps:
- download: current
artifact: drop
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: $(NETCORE_VERSION)
includePreviewVersions: false
- task: CmdLine@2
displayName: 'Install .NET MAUI Workload'
inputs:
script: 'dotnet workload install maui'
- task: JavaToolInstaller@0
displayName: 'Install Java SDK 11.0'
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
# if this is a tagged build, then update the version number
- powershell: |
$buildSourceBranch = "$(Build.SourceBranch)"
$tagVersion = "$buildSourceBranch".Substring($buildSourceBranch.LastIndexOf("/") + 1)+"-preview$(PreviewNumber)"
Write-Host("Branch = $buildSourceBranch, Version = $tagVersion");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$tagVersion")
displayName: Set NuGet Version to Tag Number
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
# restore, build and pack the packages
- task: VSBuild@1
displayName: 'Pack Community Toolkit NuGets'
inputs:
solution: '$(Pipeline.Workspace)\drop\$(PathToMauiCompatCommunityToolkitCsproj)'
configuration: 'Release'
msbuildArgs: '/restore -t:pack -p:PackageVersion=$(NugetPackageVersion) -p:Version=$(NugetPackageVersion) -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg'
- task: VSBuild@1
displayName: 'Build and Pack Markup NuGet'
inputs:
solution: '$(Pipeline.Workspace)\drop\$(PathToMauiCompatMarkupCsproj)'
configuration: 'Release'
msbuildArgs: '/restore -t:pack -p:PackageVersion=$(NugetPackageVersion) -p:Version=$(NugetPackageVersion) -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg'
# publish the packages
- task: PowerShell@2
displayName: 'Copy NuGet Packages to Staging Directory'
inputs:
targetType: 'inline'
script: |
$source = "$(Pipeline.Workspace)\drop\src"
$filter = "nupkg"
Get-ChildItem -Path $source -Recurse | Where-Object { $_.Extension -match $filter } | Copy-Item -Destination "$(Build.ArtifactStagingDirectory)"
pwsh: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Unsigned NuGets'
inputs:
artifactName: nuget
pathToPublish: '$(Build.ArtifactStagingDirectory)'
# make sure we are following the rules, but only on the main build
- ${{ if eq(variables['System.TeamProject'], 'devdiv') }}:
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
displayName: Component Detection - Log
inputs:
scanType: LogOnly
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
displayName: Component Detection - Report
- task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@1
condition: eq(variables['RunPoliCheck'], 'true')
displayName: 'PoliCheck'
inputs:
targetType: F
- job: build_macos
displayName: Build macOS Library
pool:
vmImage: macos-latest
steps:
# if this is a tagged build, then update the version number
- powershell: |
$buildSourceBranch = "$(Build.SourceBranch)"
$tagVersion = $buildSourceBranch.Substring($buildSourceBranch.LastIndexOf("/") + 1)
Write-Host("Branch = $buildSourceBranch, Version = $tagVersion");
Write-Host ("##vso[task.setvariable variable=NugetPackageVersion;]$tagVersion")
displayName: Set NuGet Version to Tag Number
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: $(NETCORE_VERSION)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Install .NET 3.1 Test SDK'
inputs:
version: $(NETCORE_TEST_VERSION_3_1)
includePreviewVersions: false
- task: UseDotNet@2
displayName: 'Install .NET 2.1 Test SDK'
inputs:
version: $(NETCORE_TEST_VERSION_2_1)
includePreviewVersions: false
# restore, build and pack the packages
- task: MSBuild@1
displayName: Build Xamarin.CommunityToolkit.csproj
inputs:
solution: $(PathToCommunityToolkitCsproj)
configuration: Release
msbuildArguments: '/restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- task: MSBuild@1
displayName: Pack Community Toolkit NuGets
inputs:
solution: $(PathToCommunityToolkitCsproj)
configuration: Release
msbuildArguments: '/t:Pack /p:PackageVersion=$(NugetPackageVersion)'
- task: MSBuild@1
displayName: Build Markup Project
inputs:
solution: $(PathToMarkupCsproj)
configuration: Release
msbuildArguments: '/restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- task: MSBuild@1
displayName: Pack Markup NuGet
inputs:
solution: $(PathToMarkupCsproj)
configuration: Release
msbuildArguments: '/t:Pack /p:PackageVersion=$(NugetPackageVersion)'
- task: CmdLine@2
displayName: 'Run Markup Unit Tests'
inputs:
script: 'dotnet test $(PathToMarkupUnitTestCsproj) -c Release -p:BuildInParallel=false'
- task: CmdLine@2
displayName: 'Run Community Toolkit Unit Tests'
inputs:
script: 'dotnet test $(PathToCommunityToolkitUnitTestCsproj) -c Release -p:BuildInParallel=false'
- ${{ if eq(variables['System.TeamProject'], 'devdiv') }}:
- template: sign-artifacts/jobs/v2.yml@internal-templates
parameters:
dependsOn: [ build_windows ]
condition: and(succeeded(), or(eq(variables['Sign'], 'true'), startsWith(variables['Build.SourceBranch'],'refs/tags/')))