forked from nanoframework/metadata-processor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
333 lines (278 loc) · 9.8 KB
/
azure-pipelines.yml
File metadata and controls
333 lines (278 loc) · 9.8 KB
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
trigger:
branches:
include: [main, develop, "release-*" ]
paths:
exclude: [README.md, LICENSE.md, NuGet.Config, .github_changelog_generator, .gitignore]
tags:
include: ["v*"]
# PR always trigger build
# add nf-tools repo to resources (for Azure Pipelines templates)
resources:
repositories:
- repository: templates
type: github
name: nanoframework/nf-tools
endpoint: nanoframework
jobs:
##############################
- job: Get_Build_Flags
pool:
vmImage: 'windows-2019'
steps:
- checkout: self
fetchDepth: 1
# get commit message
- powershell: |
# default to false
$update = $false
if($env:Build_Reason -eq 'PullRequest')
{
# PR build, nothing interesting in commit message
}
else
{
# build is not from a PR
# get commit ID
$commitId = git rev-parse HEAD
# get PR associate with commit
$prUrl = "https://api.github.com/repos/nanoframework/metadata-processor/commits/$commitId/pulls"
$commit = Invoke-RestMethod -Uri $prUrl -ContentType "application/json" -Headers @{"Accept"="application/vnd.github.groot-preview+json"} -Method GET
if($commit -ne $null)
{
# there is a PR, check labels
$updateDependents = $commit.labels | where {$_.Name -eq 'CI: Update Dependents'}
if($updateDependents -ne $null)
{
$update = $true
}
}
else
{
# not a PR, get subject and commit message for commit
$commitMessage = git log --format='%B' -1
# need to flatten message by removing new lines
$commitMessage = $commitMessage -replace "`r`n", " "
if($commitMessage -like "***UPDATE_DEPENDENTS***")
{
$update = $true
}
}
}
# set variable to foward to jobs
echo "##vso[task.setvariable variable=RUN_UPDATE_DEPENDENTS;isOutput=true]$update"
name: GetPRLabels
displayName: Check build labels
##############################
# build MDP
- job: Build_MDP
condition: eq(variables['UPDATE_DEPENDENTS'], 'false')
dependsOn:
- Get_Build_Flags
pool:
vmImage: 'windows-2019'
variables:
DOTNET_NOLOGO: true
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
solution: 'nanoFramework.Tools.MetadataProcessor.sln'
NF_MDP_MSBUILDTASK_PATH: '$(System.DefaultWorkingDirectory)/MetadataProcessor.MsBuildTask/bin/Release'
steps:
# need this here in order to persist GitHub credentials, do a shallow fetch AND init submodules
- checkout: self
persistCredentials: true
submodules: true
- script: |
git config --global user.email "[email protected]"
git config --global user.name "nfbot"
displayName: Setup git identity
- template: azure-pipelines-templates/install-nuget.yml@templates
- task: DotNetCoreCLI@2
displayName: Install NBGV tool
inputs:
command: custom
custom: tool
arguments: install -g nbgv
- task: InstallnFBuildComponents@1
condition: ne( variables['StartReleaseCandidate'], true )
displayName: Install nanoFramework MSBuild components
- task: NuGetToolInstaller@1
condition: succeeded()
displayName: 'Install specific version of NuGet'
inputs:
versionSpec: '5.9.0'
- task: NuGetCommand@2
displayName: NuGet restore
inputs:
restoreSolution: '$(solution)'
feedsToUse: config
nugetConfigPath: 'NuGet.config'
- task: NuGetCommand@2
displayName: NuGet restore mscorlib
inputs:
restoreSolution: 'MetadataProcessor.Tests\mscorlib\nanoFramework.CoreLibrary.sln'
feedsToUse: config
nugetConfigPath: 'NuGet.config'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
msbuildArgs: '/p:PublicRelease=true'
configuration: '$(buildConfiguration)'
- script: nbgv cloud -a -c
condition: succeeded()
displayName: Set Could Version
- task: PowerShell@2
displayName: Remove nano Test Adapter
inputs:
targetType: 'inline'
script: |
Get-ChildItem -Path $env:System_DefaultWorkingDirectory -Include "nanoFramework.TestAdapter.dll" -Recurse |
Foreach-object {
Remove-Item -Path $_.fullname
}
- task: VisualStudioTestPlatformInstaller@1
condition: succeeded()
displayName: 'Visual Studio Test Platform Installer'
inputs:
versionSelector: latestStable
- task: VSTest@2
condition: succeeded()
displayName: 'Running tests'
inputs:
testSelector: 'testAssemblies'
pathtoCustomTestAdapters:
testAssemblyVer2: |
**\*Tests*.dll
!**\*TestAdapter*.dll
!**\*TestFramework*.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
diagnosticsEnabled: true
vsTestVersion: toolsInstaller
codeCoverageEnabled: true
- task: CopyFiles@1
condition: succeeded()
displayName: Collecting deployable artifacts
inputs:
sourceFolder: $(Build.SourcesDirectory)
Contents: |
**\bin\Release\nanoFramework.Tools.MetaDataProcessor.exe
**\bin\Release\nanoFramework.Tools.MetadataProcessor.MsBuildTask.dll
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
- task: NuGetCommand@2
condition: succeeded()
displayName: Pack NuGet with MDP MSBuild task
inputs:
command: 'custom'
arguments: 'pack MetadataProcessor.MsBuildTask\package.nuspec -Version $(NBGV_NuGetPackageVersion) -properties commit="$(Build.SourceVersion)"'
- task: CopyFiles@1
condition: succeeded()
displayName: Collecting NuGet package artifact
inputs:
sourceFolder: $(Build.SourcesDirectory)
Contents: |
**\nanoFramework.Tools*.nupkg
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
- task: DotNetCoreCLI@2
displayName: Install SignTool tool
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
inputs:
command: custom
custom: tool
arguments: install --tool-path . SignClient
- pwsh: |
.\SignClient "Sign" `
--baseDirectory "$(Build.ArtifactStagingDirectory)" `
--input "**/*.nupkg" `
--config "$(Build.Repository.LocalPath)\config\SignClient.json" `
--filelist "$(Build.Repository.LocalPath)\config\filelist.txt" `
--user "$(SignClientUser)" `
--secret '$(SignClientSecret)' `
--name ".NET nanoFramework Metadata Processor" `
--description ".NET nanoFramework Metadata Processor" `
--descriptionUrl "https://github.com/$env:Build_Repository_Name"
displayName: Sign packages
continueOnError: true
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
# publish artifacts (only possible if this is not a PR originated on a fork)
- task: PublishBuildArtifacts@1
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
displayName: Publish deployables artifacts
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: deployables
ArtifactType: Container
# push NuGet packages to Azure Artifacts feed (always happens except on PR builds)
- task: NuGetCommand@2
displayName: Push NuGet packages to Azure Artifacts
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], '') )
continueOnError: true
inputs:
command: push
nuGetFeedType: external
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
publishFeedCredentials: 'AzureArtifacts'
allowPackageConflicts: true
# create or update GitHub release
- task: GithubRelease@1
condition: and( succeeded(), eq(variables['System.PullRequest.PullRequestId'], ''), not( startsWith(variables['Build.SourceBranch'], 'refs/tags/v') ) )
displayName: Create/Update GitHub release
inputs:
gitHubConnection: 'github.com_nano-$(System.TeamProject)'
tagSource: userSpecifiedTag
tag: v$(GitBuildVersionSimple)
title: 'nanoFramework Metadata Processor v$(GitBuildVersionSimple)'
releaseNotesSource: inline
releaseNotesInline: 'add description here'
assets: '$(Build.ArtifactStagingDirectory)/*'
assetUploadMode: replace
isPreRelease: false
addChangeLog: false
##############################
- job: Update_Dependents
condition: and( or( eq(dependencies.Get_Build_Flags.outputs['GetPRLabels.RUN_UPDATE_DEPENDENTS'], 'true'), eq(variables['UPDATE_DEPENDENTS'], 'true') ), not( startsWith(variables['Build.SourceBranch'], 'refs/tags/v') ) )
dependsOn:
- Get_Build_Flags
- Build_MDP
pool:
vmImage: 'windows-2019'
variables:
DOTNET_NOLOGO: true
steps:
# need this here in order to persist GitHub credentials
- checkout: self
fetchDepth: 100
- template: azure-pipelines-templates/install-nbgv-tool.yml@templates
- template: azure-pipelines-templates/install-nuget.yml@templates
- script: nbgv cloud -a -c
condition: succeeded()
displayName: Set build number
# update dependencies
- task: PowerShell@2
displayName: Update dependent class libs
inputs:
targetType: filePath
filePath: azure-pipelines/update-dependencies.ps1
env:
MY_GITHUB_TOKEN: $(GitHubToken)
##################################
# report build failure to Discord
- job: Report_Build_Failure
dependsOn:
- Build_MDP
condition: failed('Build_MDP')
pool:
vmImage: 'windows-2019'
steps:
- checkout: self
fetchDepth: 1
# step from template @ nf-tools repo
- template: azure-pipelines-templates/discord-webhook.yml@templates
parameters:
status: 'failure'
webhookUrl: '$(DiscordWebhook)'
message: ''