forked from nanoframework/nf-Visual-Studio-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
514 lines (445 loc) · 17 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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
trigger:
branches:
include:
- main
- develop
- release-*
paths:
exclude:
- README.md
- LICENSE.md
- CHANGELOG*.md
- NuGet.Config
- .github_changelog_generator
- .gitignore
# PR always trigger build
pr:
autoCancel: true
# 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_Options
pool:
vmImage: 'windows-latest'
steps:
- checkout: self
# check which project(s) have changed
- powershell: |
git config --global user.email "nfbot"
git config --global user.name "[email protected]"
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$(GitHubToken)"))))"
$commit = Invoke-RestMethod -Uri "https://api.github.com/repos/nanoframework/nf-Visual-Studio-extension/commits/$(Build.SourceVersion)" -Header @{"Authorization"="$auth"} -ContentType "application/json" -Method GET
Write-host "Files changed:"
$commit.files | % {$_.filename}
# default values
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]false"
if( ($commit.files.filename -like "*CSharp.AssemblyInfoTemplate*") -Or
($commit.files.filename -like "*CSharp.BlankApplication*") -Or
($commit.files.filename -like "*CSharp.ClassLibrary*") -Or
($commit.files.filename -like "*CSharp.ClassTemplate*") -Or
($commit.files.filename -like "*CSharp.ResourceTemplate*") -Or
($commit.files.filename -like "*CSharp.TestApplication*") -Or
($commit.files.filename -like "*Tools.BuildTasks-2019*") -Or
($commit.files.filename -like "*Tools.BuildTasks-2022*") -Or
($commit.files.filename -like "*vs-extension.shared*") -Or
($commit.files.filename -like "*azure-pipelines.yml")
)
{
# global changes, build both
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]true"
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]true"
}
else
{
if( $commit.files.filename -like "*nanoFramework.Tools.VisualStudio.sln")
{
# changes here impact VS2022 and VS2019
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]true"
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]true"
}
if( $commit.files.filename -like "*VisualStudio.Extension-2019/*" )
{
# changes here only impact VS2019
echo "##vso[task.setvariable variable=BUILD_VS2019;isOutput=true]true"
}
if( $commit.files.filename -like "*VisualStudio.Extension-2022/*" )
{
# changes here only impact VS2022
echo "##vso[task.setvariable variable=BUILD_VS2022;isOutput=true]true"
}
}
name: BuildOptions
displayName: Get what to build
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
- powershell: |
# read VS2019 manifest file
$vs2019Manifest = Get-Content VisualStudio.Extension-2019/source.extension.vsixmanifest -Encoding utf8
$VersionFormatChecks = $vs2019Manifest | Where-Object {$_.ToString() -match "(?>Version=""\|%CurrentProject%;GetBuildVersion\|"")"}
if($null -eq $VersionFormatChecks)
{
Write-Host "***************************************************"
Write-Host "* WRONG format on version in VS2019 manifest file *"
Write-Host "***************************************************"
exit 1
}
# read VS2022 manifest file
$vs2022Manifest = Get-Content VisualStudio.Extension-2022/source.extension.vsixmanifest -Encoding utf8
$VersionFormatChecks = $vs2022Manifest | Where-Object {$_.ToString() -match "(?>Version=""\|%CurrentProject%;GetBuildVersion\|"")"}
if($null -eq $VersionFormatChecks)
{
Write-Host "***************************************************"
Write-Host "* WRONG format on version in VS2022 manifest file *"
Write-Host "***************************************************"
exit 1
}
displayName: Check proper version format
######################
- job: VS2019
condition: >-
or(
eq(dependencies.Get_Build_Options.outputs['BuildOptions.BUILD_VS2019'], true),
eq(variables['BUILD_VS2019'], 'true'),
startsWith(variables['Build.SourceBranch'], 'refs/tags/v2019')
)
dependsOn:
- Get_Build_Options
pool:
vmImage: 'windows-latest'
variables:
- group: sign-client-credentials
- name: DOTNET_NOLOGO
value: true
- name: buildConfiguration
value: 'Release'
- name: solution
value: 'VisualStudio.Extension-2019/VisualStudio.Extension-vs2019.csproj'
steps:
# need this here in order to persist GitHub credentials AND init submodules
- checkout: self
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: NuGetCommand@2
inputs:
restoreSolution: 'nanoFramework.Tools.VisualStudio.sln'
feedsToUse: config
nugetConfigPath: NuGet.config
verbosityRestore: quiet
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:PublicRelease=true'
configuration: '$(buildConfiguration)'
maximumCpuCount: true
# we don't have tests (yet)
# - task: VSTest@2
# inputs:
# platform: '$(buildPlatform)'
# configuration: '$(buildConfiguration)'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$versionData = & nbgv get-version -f json -p VisualStudio.Extension-2019
$versionData =$versionData | ConvertFrom-Json
$version = $versionData.AssemblyVersion
Write-Host "VS2019 build version $version"
echo "##vso[task.setvariable variable=BUILD_VERSION;isOutput=true]$version"
condition: succeeded()
name: VS2019_Build
displayName: Store VS2019 build version
- task: CopyFiles@1
inputs:
sourceFolder: $(Build.SourcesDirectory)
Contents: |
**\*VS2019.Extension.vsix
**\vs2019-extension-manifest.json
**\vs2019-marketplace-overview.md
**\vs2019\debug-session.png
**\vs2019\starting-new-project.png
TargetFolder: '$(Build.ArtifactStagingDirectory)\vs2019'
flattenFolders: true
condition: succeeded()
displayName: Collecting VS2019 deployable artifacts
- task: DotNetCoreCLI@2
displayName: Install SignTool tool
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], '')
)
inputs:
command: custom
custom: tool
arguments: install --tool-path . sign --version 0.9.1-beta.24170.3
- pwsh: |
.\sign code azure-key-vault `
"**/*.vsix" `
--base-directory "$(Build.ArtifactStagingDirectory)\vs2019" `
--file-list "$(Build.Repository.LocalPath)\config\filelist.txt" `
--description ".NET nanoFramework VS2019 Extension" `
--description-url "https://github.com/$env:Build_Repository_Name" `
--azure-key-vault-tenant-id "$(SignTenantId)" `
--azure-key-vault-client-id "$(SignClientId)" `
--azure-key-vault-client-secret "$(SignClientSecret)" `
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
--azure-key-vault-url "$(SignKeyVaultUrl)" `
--timestamp-url http://timestamp.digicert.com
displayName: Sign VS2019 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
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: deployables
ArtifactType: Container
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
displayName: Publish deployables artifacts
# upload extension to Open VSIX Gallery (only possible if this is not a PR from a fork)
- task: PowerShell@2
displayName: Upload vsix to Open VSIX Gallery
condition: >-
and(
succeeded(),
ne(variables['system.pullrequest.isfork'], true),
eq(variables['System.PullRequest.PullRequestId'], '')
)
continueOnError: true
inputs:
targetType: 'inline'
script: |
$artifactsCollection = @("./*VS2019.Extension.vsix") | %{ Get-ChildItem -File . -Filter $_ -Recurse}
(new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex
foreach($file in $artifactsCollection)
{
"Uploading VSIX package to Open VSIX Gallery..." | Write-Host
Vsix-PublishToGallery $file
}
# 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$(VS2019_Build.BUILD_VERSION)
title: '.NET nanoFramework VS Extension v$(VS2019_Build.BUILD_VERSION)'
assets: '$(Build.ArtifactStagingDirectory)/**/*.vsix'
assetUploadMode: replace
isPreRelease: false
isDraft: true
addChangeLog: true
changeLogType: issueBased
lastNonDraftReleaseByTag: 'v2019\.[\d.]+'
changeLogLabels: |
[
{ "label" : "Type: bug", "displayName" : "Bugs fixed", "state" : "closed" },
{ "label" : "Type: enhancement", "displayName" : "Enhancements and new features", "state" : "closed" },
{ "label" : "Breaking-Change", "displayName" : "Breaking Changes", "state" : "closed" }
{ "label" : "Type: dependencies", "displayName" : "Dependencies updated", "state" : "closed" },
{ "label" : "Type: documentation", "displayName" : "Documentation", "state" : "closed" }
]
######################
- job: VS2022
condition: >-
or(
eq(dependencies.Get_Build_Options.outputs['BuildOptions.BUILD_VS2022'], true),
eq(variables['BUILD_VS2022'], 'true'),
startsWith(variables['Build.SourceBranch'], 'refs/tags/v2022')
)
dependsOn:
- Get_Build_Options
pool:
vmImage: 'windows-latest'
variables:
- group: sign-client-credentials
- name: DOTNET_NOLOGO
value: true
- name: buildConfiguration
value: 'Release'
- name: solution
value: 'VisualStudio.Extension-2022/VisualStudio.Extension-vs2022.csproj'
steps:
# need this here in order to persist GitHub credentials AND init submodules
- checkout: self
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: NuGetCommand@2
inputs:
restoreSolution: 'nanoFramework.Tools.VisualStudio.sln'
feedsToUse: config
nugetConfigPath: NuGet.config
verbosityRestore: quiet
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:PublicRelease=true'
configuration: '$(buildConfiguration)'
maximumCpuCount: true
msbuildArchitecture: 'x64'
platform: 'x64'
# we don't have tests (yet)
# - task: VSTest@2
# inputs:
# platform: '$(buildPlatform)'
# configuration: '$(buildConfiguration)'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$versionData = & nbgv get-version -f json -p VisualStudio.Extension-2022
$versionData =$versionData | ConvertFrom-Json
$version = $versionData.AssemblyVersion
Write-Host "VS2022 build version $version"
echo "##vso[task.setvariable variable=BUILD_VERSION;isOutput=true]$version"
condition: succeeded()
name: VS2022_Build
displayName: Store VS2022 build version
- task: CopyFiles@1
inputs:
sourceFolder: $(Build.SourcesDirectory)
Contents: |
**\*VS2022.Extension.vsix
**\vs2022-extension-manifest.json
**\vs2022-marketplace-overview.md
**\vs2022\debug-session.png
**\vs2022\starting-new-project.png
TargetFolder: '$(Build.ArtifactStagingDirectory)\vs2022'
flattenFolders: true
condition: succeeded()
displayName: Collecting VS2022 deployable artifacts
- task: DotNetCoreCLI@2
displayName: Install SignTool tool
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], '')
)
inputs:
command: custom
custom: tool
arguments: install --tool-path . sign --version 0.9.1-beta.24170.3
- pwsh: |
.\sign code azure-key-vault `
"**/*.vsix" `
--base-directory "$(Build.ArtifactStagingDirectory)\vs2022" `
--file-list "$(Build.Repository.LocalPath)\config\filelist.txt" `
--description ".NET nanoFramework VS2022 Extension" `
--description-url "https://github.com/$env:Build_Repository_Name" `
--azure-key-vault-tenant-id "$(SignTenantId)" `
--azure-key-vault-client-id "$(SignClientId)" `
--azure-key-vault-client-secret "$(SignClientSecret)" `
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
--azure-key-vault-url "$(SignKeyVaultUrl)" `
--timestamp-url http://timestamp.digicert.com
displayName: Sign VS2022 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
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: deployables
ArtifactType: Container
condition: and( succeeded(), ne(variables['system.pullrequest.isfork'], true) )
displayName: Publish deployables artifacts
# upload extension to Open VSIX Gallery (only possible if this is not a PR from a fork)
- task: PowerShell@2
displayName: Upload vsix to Open VSIX Gallery
condition: >-
and(
succeeded(),
ne(variables['system.pullrequest.isfork'], true),
eq(variables['System.PullRequest.PullRequestId'], '')
)
continueOnError: true
inputs:
targetType: 'inline'
script: |
$artifactsCollection = @("./*VS2022.Extension.vsix") | %{ Get-ChildItem -File . -Filter $_ -Recurse}
(new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex
foreach($file in $artifactsCollection)
{
"Uploading VSIX package to Open VSIX Gallery..." | Write-Host
Vsix-PublishToGallery $file
}
# 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$(VS2022_Build.BUILD_VERSION)
title: '.NET nanoFramework VS Extension v$(VS2022_Build.BUILD_VERSION)'
assets: '$(Build.ArtifactStagingDirectory)/**/*.vsix'
assetUploadMode: replace
isDraft: true
isPreRelease: false
addChangeLog: true
changeLogType: issueBased
lastNonDraftReleaseByTag: 'v2022\.[\d.]+'
changeLogLabels: |
[
{ "label" : "Type: bug", "displayName" : "Bugs fixed", "state" : "closed" },
{ "label" : "Type: enhancement", "displayName" : "Enhancements and new features", "state" : "closed" },
{ "label" : "Breaking-Change", "displayName" : "Breaking Changes", "state" : "closed" },
{ "label" : "Type: dependencies", "displayName" : "Dependencies updated", "state" : "closed" },
{ "label" : "Type: documentation", "displayName" : "Documentation", "state" : "closed" }
]
##################################
# report build failure to Discord
- job: Report_Build_Failure
dependsOn:
- VS2019
- VS2022
condition: >-
or(
failed('VS2019'),
failed('VS2022')
)
pool:
vmImage: 'windows-latest'
steps:
- checkout: self
fetchDepth: 1
# step from template @ nf-tools repo
# report error
- template: azure-pipelines-templates/discord-webhook.yml@templates
parameters:
status: 'failure'
webhookUrl: '$(DiscordWebhook)'
message: ''