forked from xamarin/XamarinCommunityToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
246 lines (238 loc) · 10.7 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
# See available software and versions on hosted agents here: https://docs.microsoft.com/azure/devops/pipelines/agents/hosted
variables:
CurrentSemanticVersionBase: '1.1.0'
PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)]
CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)'
NugetPackageVersion: '$(CurrentSemanticVersion)'
#MONO_VERSION: 6_4_0
#XCODE_VERSION: 11.4
NETCORE_VERSION: '5.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'
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'
PathToMsBuildOnMacOS: 'mono /Applications/Visual\ studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/MSBuild.dll'
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:
- develop
jobs:
- job: build_windows_samples
displayName: Build Windows Samples
pool:
vmImage: windows-2019
steps:
- task: CmdLine@2
displayName: 'Clear Local NuGet Cache' #https://github.com/actions/virtual-environments/issues/1090#issuecomment-748452120
inputs:
script: 'nuget locals all -clear'
- task: MSBuild@1
displayName: 'Clean Solution'
inputs:
solution: $(PathToSamplesSln)
msbuildArguments: '/t:Clean'
- 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
- task: CmdLine@2
displayName: 'Clear Local NuGet Cache' #https://github.com/actions/virtual-environments/issues/1090#issuecomment-748452120
inputs:
script: 'nuget locals all -clear'
- task: MSBuild@1
displayName: 'Clean Solution'
inputs:
solution: $(PathToSamplesSln)
msbuildArguments: '/t:Clean'
# 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/')
# 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)/nuget'
- task: MSBuild@1
displayName: Pack Community Toolkit NuGets
inputs:
solution: $(PathToCommunityToolkitCsproj)
configuration: Release
msbuildArguments: '/t:Pack /p:PackageVersion=$(NugetPackageVersion) /p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/nuget"'
- 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) /p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/nuget"'
# - task: DotNetCoreCLI@2
# displayName: Publish to GitHub NuGet Packages
# condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/main'))
# inputs:
# command: 'custom'
# custom: 'nuget'
# arguments: 'push --source https://nuget.pkg.github.com/xamarin/index.json --api-key $(GitHub.NuGet.Token) "$(Build.ArtifactStagingDirectory)\nuget\*.nupkg"'
- 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: PublishBuildArtifacts@1
displayName: 'Publish Unsigned NuGets'
inputs:
artifactName: nuget
pathToPublish: '$(Build.ArtifactStagingDirectory)/nuget'
# 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-10.15
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/')
# 16feb21 jfversluis: let's not pin this anymore and use latest
# make sure to select the correct Xamarin and mono
#- bash: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh $(MONO_VERSION)
# displayName: Switch to the latest Xamarin SDK
#- bash: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'/Applications/Xcode_$(XCODE_VERSION).app;sudo xcode-select --switch /Applications/Xcode_$(XCODE_VERSION).app/Contents/Developer
# displayName: Switch to the latest Xcode
# restore, build and pack the packages
- 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
- task: CmdLine@2
displayName: 'Build Markup'
inputs:
script: '$(PathToMsBuildOnMacOS) $(PathToMarkupCsproj) /p:Configuration=Release /restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- task: CmdLine@2
displayName: 'Build Community Toolkit'
inputs:
script: '$(PathToMsBuildOnMacOS) $(PathToCommunityToolkitCsproj) /p:Configuration=Release /restore /t:Build /p:ContinuousIntegrationBuild=true /p:Deterministic=false'
- 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'
- task: CmdLine@2
displayName: 'Pack Markup NuGets'
inputs:
script: '$(PathToMsBuildOnMacOS) $(PathToMarkupUnitTestCsproj) /p:Configuration=Release /t:Pack /p:PackageVersion=$(NugetPackageVersion) /p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/nuget"'
- task: CmdLine@2
displayName: 'Pack CommunityToolkit NuGets'
inputs:
script: '$(PathToMsBuildOnMacOS) $(PathToCommunityToolkitCsproj) /p:Configuration=Release /t:Pack /p:PackageVersion=$(NugetPackageVersion) /p:PackageOutputPath="$(Build.ArtifactStagingDirectory)/nuget"'
- ${{ 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'), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'],'refs/tags/'))))