forked from nanoframework/nf-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
556 lines (484 loc) · 19 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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
trigger:
branches:
include:
- main
- develop*
- release-*
- refs/tags/*
paths:
exclude:
- .clang-format
- .github_changelog_generator
- .gitignore
- .typo-ci.yml
- build.ps1
- CHANGELOG.md
- CMakeSettings.json
- CMakeSettings.SAMPLE.json
- LICENSE.md
- nf.props
- nfcore.vssettings
- README.md
- README.zh-cn.md
- RunCmd.bat
- startocd.bat
- .github/*
- .devcontainer/*
- .vscode/*
- .vs/*
- assets/*
- config/*
- install-scripts/*
- VisualStudioDevelopment/*
pr:
autoCancel: true
# add nf-tools repo to resources (for Azure Pipelines templates)
resources:
repositories:
- repository: templates
type: github
name: nanoframework/nf-tools
endpoint: markusschweitzer
- repository: esp32_idf
type: github
name: espressif/esp-idf
endpoint: markusschweitzer
ref: 'refs/tags/v5.1.4'
- repository: mscorlib
type: github
name: nanoframework/CoreLibrary
endpoint: markusschweitzer
jobs:
##############################
- job: Check_Build_Options
pool:
vmImage: "windows-latest"
variables:
DOTNET_NOLOGO: true
steps:
- checkout: self
fetchDepth: 1
# get commit message
- powershell: |
# set default values
echo "##vso[task.setvariable variable=RUN_MSCORLIB_TESTS;isOutput=true]false"
if($env:StartReleaseCandidate -like "true")
{
# this is a release prep so NO build
echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]true"
Write-Host "##[command] Release preparation, skipping build."
}
else
{
# get commit details, if this is a PR
if($env:System_PullRequest_PullRequestId -ne $null)
{
Write-Host "##[command] **This is a PR build**"
$commit = Invoke-RestMethod -Uri "https://api.github.com/repos/markusschweitzer/nf-interpreter/commits/$(Build.SourceVersion)" -ContentType "application/json" -Method GET
if( ($commit.commit.author.name -eq "nfbot") -and ($commit.commit.message -like "*[version update]*") )
{
echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]true"
}
else
{
echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]false"
}
# check if Unit Tests for mscorlib should be run
if($commit.commit.message -like "*[run mscorlib tests]*")
{
echo "##vso[task.setvariable variable=RUN_MSCORLIB_TESTS;isOutput=true]true"
}
}
else
{
Write-Host "##[command] **build for other reasons**"
echo "##vso[task.setvariable variable=SKIP_BUILD;isOutput=true]false"
}
}
name: BuildOptions
displayName: Get build options
# check what changed
- powershell: |
echo "##vso[task.setvariable variable=BUILD_CHIBIOS;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_FREERTOS;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_ESP32;isOutput=true]true"
echo "##vso[task.setvariable variable=BUILD_TI;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_AZURERTOS;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_WIN32;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_NANOCLR_CLI;isOutput=true]false"
echo "##vso[task.setvariable variable=BUILD_ALL;isOutput=true]false"
name: TargetsToBuild
displayName: Get targets to build
- task: DotNetCoreCLI@2
condition: eq( variables['StartReleaseCandidate'], true )
displayName: Install NBGV tool
inputs:
command: custom
custom: tool
arguments: install -g nbgv
- powershell: |
# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))"
cd "$env:Agent_TempDirectory" > $null
git init "$env:Agent_TempDirectory\repo"
cd repo > $null
git remote add origin "$env:Build_Repository_Uri"
git config --global gc.auto 0
git config --global user.name nfbot
git config --global user.email [email protected]
git config --global core.autocrlf true
git -c http.extraheader="AUTHORIZATION: $auth" fetch --progress origin
git checkout develop
# prepare release and capture output
$release = nbgv prepare-release
# push all changes to github
git -c http.extraheader="AUTHORIZATION: $auth" push --all origin
# get release branch name
$branch = $release.Split(' ')[0]
# start PR for release
$prRequestBody = @{title="Release $branch";body="";head="$branch";base="main"} | ConvertTo-Json
$githubApiEndpoint = "https://api.github.com/repos/$env:Build_Repository_Name/pulls"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$headers = @{}
$headers.Add("Authorization","$auth")
$headers.Add("Accept","application/vnd.github.symmetra-preview+json")
try
{
$result = Invoke-RestMethod -Method Post -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::InternetExplorer -Uri $githubApiEndpoint -Header $headers -ContentType "application/json" -Body $prRequestBody
'Started PR for new release...' | Write-Host -NoNewline
'##[error] OK' | Write-Host -ForegroundColor Green
}
catch
{
$result = $_.Exception.Response.GetResponseStream()
$reader = New-Object System.IO.StreamReader($result)
$reader.BaseStream.Position = 0
$reader.DiscardBufferedData()
$responseBody = $reader.ReadToEnd();
"##[error] Error starting PR: $responseBody" | Write-Host -ForegroundColor Red
}
condition: eq( variables['StartReleaseCandidate'], true )
displayName: NBGV prepare release
##############################
- job: Check_Code_Style
condition: >-
and(
ne(dependencies.Check_Build_Options.outputs['BuildOptions.SKIP_BUILD'], true),
or(
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ALL'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_CHIBIOS'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ESP32'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_FREERTOS'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_TI'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_AZURERTOS'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_WIN32'], true)
)
)
dependsOn:
- Check_Build_Options
pool:
vmImage: "windows-latest"
steps:
- checkout: self
fetchDepth: 1
condition: ne(variables['System.PullRequest.PullRequestId'], '')
- template: azure-pipelines-templates/download-install-llvm.yml
- template: azure-pipelines-templates/check-code-style.yml
#################
# ESP32 targets
- job: Build_ESP32_targets
condition: >-
or(
and(
succeeded('Check_Code_Style'),
ne( dependencies.Check_Build_Options.outputs['BuildOptions.SKIP_BUILD'], true ),
or(
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ALL'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ESP32'], true)
)
),
and(
eq(variables['Build.Reason'], 'Manual'),
or(
eq(variables['BUILD_ALL__'], 'true'),
eq(variables['BUILD_ESP32__'], 'true')
)
)
)
dependsOn:
- Check_Build_Options
- Check_Code_Style
pool:
vmImage: "windows-latest"
# there is only a single ESP32 target, but this is already config as a matrix to make it easy to add new ones
strategy:
matrix:
ESP32_S3_ALL:
TargetBoard: ESP32_S3
TargetSeries: "esp32s3"
BuildOptions:
IDF_Target: esp32s3
TargetName: ESP32_S3_ALL
PackageName: ESP32_S3_ALL
CMakePreset: ESP32_S3_ALL
variables:
DOTNET_NOLOGO: true
# creates a counter and assigns it to the revision variable
REVISION: $[counter('ESP32_1_10_0_versioncounter', 0)]
IDF_PATH: "D:/a/1/s/esp-idf"
PIP_CACHE_DIR: $(Pipeline.Workspace)/.pip
TargetPlatform: "esp32"
steps:
- checkout: self
- checkout: esp32_idf
fetchDepth: 1
- template: azure-pipelines-templates/build-preparations.yml
parameters:
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
- template: azure-pipelines-templates/nb-gitversioning.yml
parameters:
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
- template: azure-pipelines-templates/download-install-esp32-build-components.yml
- template: azure-pipelines-templates/download-install-ninja.yml
parameters:
repoDirectory: '$(Build.SourcesDirectory)\nf-interpreter'
- template: azure-pipelines-templates/build-espressif-esp32-targets.yml
- task: CopyFiles@2
condition: succeeded()
displayName: Copying bootloader
inputs:
sourceFolder: '$(Build.SourcesDirectory)\nf-interpreter\build\bootloader'
Contents: |
bootloader.bin
TargetFolder: '$(Build.ArtifactStagingDirectory)\$(TargetPublishName)'
flattenFolders: true
ignoreMakeDirErrors: true
- template: azure-pipelines-templates/copy-sdkconfig.yml
- template: azure-pipelines-templates/pack-publish-artifacts.yml
parameters:
buildDirectory: '$(Build.SourcesDirectory)\nf-interpreter\build'
- template: azure-pipelines-templates/publish-cloudsmith.yml
- template: azure-pipelines-templates/publish-sdkconfig.yml
#################
# WIN32 executable
- job: Build_WIN32_nanoCLR
condition: >-
or(
and(
succeeded('Check_Code_Style'),
ne( dependencies.Check_Build_Options.outputs['BuildOptions.SKIP_BUILD'], true ),
or(
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ALL'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_WIN32'], true)
)
),
and(
eq(variables['Build.Reason'], 'Manual'),
or(
eq(variables['BUILD_ALL__'], 'true'),
eq(variables['BUILD_WINDOWS_NANOCLR__'], 'true')
)
)
)
dependsOn:
- Check_Build_Options
- Check_Code_Style
pool:
vmImage: "windows-latest"
variables:
- name: DOTNET_NOLOGO
value: true
# creates a counter and assigns it to the revision variable
- name: REVISION
value: $[counter('WIN32_1_10_0_versioncounter', 0)]
steps:
- template: azure-pipelines-templates/nb-gitversioning.yml
- task: PowerShell@2
displayName: Store package version
inputs:
targetType: "inline"
script: |
Write-Host "$("##vso[task.setvariable variable=WINCLR_PACKAGE_VERSION]")$(NBGV_VersionMajor).$(NBGV_VersionMinor).$(NBGV_BuildNumber).$(TARGET_BUILD_COUNTER)"
Write-Host "$("##vso[task.setvariable variable=WINCLR_AssemblyInformationalVersion]")$(NBGV_VersionMajor).$(NBGV_VersionMinor).$(NBGV_BuildNumber).$(TARGET_BUILD_COUNTER)$(NBGV_BuildMetadataFragment)"
- template: azure-pipelines-templates/install-nuget.yml@templates
- task: DotNetCoreCLI@2
displayName: Restore NuGet packages
inputs:
command: restore
restoreArguments: "--locked-mode"
verbosityRestore: minimal
projects: targets\netcore\nanoCLR.sln
feedsToUse: select
includeNuGetOrg: true
- task: VSBuild@1
displayName: Build WIN32 EXE target
inputs:
solution: 'targets\win32\nanoCLR.sln'
platform: "x86"
maximumCpuCount: true
msbuildArgs: "/p:PublicRelease=true"
configuration: "Release"
- task: VSBuild@1
displayName: Build WIN DLL target
inputs:
solution: 'targets\netcore\nanoCLR.sln'
platform: "Any CPU"
maximumCpuCount: true
msbuildArgs: "/p:PublicRelease=true"
configuration: "Release"
- task: CopyFiles@2
condition: succeeded()
displayName: Adding nanoCLR WIN32 to deployable artifacts
inputs:
sourceFolder: $(Build.SourcesDirectory)
Contents: |
**\nanoFramework.nanoCLR.exe
TargetFolder: '$(Build.ArtifactStagingDirectory)\WIN32_nanoCLR'
flattenFolders: true
ignoreMakeDirErrors: true
- task: CopyFiles@2
condition: succeeded()
displayName: Adding nanoCLR DLL to deployable artifacts
inputs:
sourceFolder: $(Build.SourcesDirectory)
Contents: |
**\nanoFramework.nanoCLR.dll
TargetFolder: '$(Build.ArtifactStagingDirectory)\WIN_DLL_nanoCLR'
flattenFolders: true
ignoreMakeDirErrors: true
# publish artifacts
- task: PublishPipelineArtifact@1
condition: succeeded()
displayName: Publish deployables artifacts
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)"
artifactName: nanoclr_win32
artifactType: pipeline
#################
# nanoCLR CLI tool
- job: Build_nanoCLR_CLI
condition: >-
or(
and(
succeeded('Check_Code_Style'),
ne(dependencies.Check_Build_Options.outputs['BuildOptions.SKIP_BUILD'], true),
or(
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_ALL'], true),
eq(dependencies.Check_Build_Options.outputs['TargetsToBuild.BUILD_NANOCLR_CLI'], true)
)
),
and(
eq(variables['Build.Reason'], 'Manual'),
or(
eq(variables['BUILD_ALL__'], 'true'),
eq(variables['BUILD_NANOCLR_CLI__'], 'true')
)
)
)
dependsOn:
- Check_Build_Options
- Check_Code_Style
pool:
vmImage: "windows-latest"
variables:
- name: DOTNET_NOLOGO
value: true
steps:
- template: azure-pipelines-templates/nb-gitversioning.yml
- template: azure-pipelines-templates/install-nuget.yml@templates
- task: DotNetCoreCLI@2
displayName: Restore NuGet packages
inputs:
command: restore
verbosityRestore: minimal
projects: targets\netcore\nanoCLR.sln
feedsToUse: select
includeNuGetOrg: true
- task: VSBuild@1
displayName: Build .NET tool
condition: succeeded()
inputs:
solution: 'targets\netcore\nanoCLR.sln'
platform: "Any CPU"
maximumCpuCount: true
msbuildArgs: "/p:PublicRelease=true"
configuration: "Release"
- task: DotNetCoreCLI@2
displayName: Install Sign Client CLI
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], '')
)
inputs:
command: custom
custom: tool
arguments: install --tool-path . sign --version 0.9.1-beta.23530.1
- pwsh: |
.\sign code azure-key-vault `
"**/nanoFramework.nanoCLR.*" `
--base-directory "$(Build.Repository.LocalPath)\build\bin\Release" `
--file-list "$(Build.Repository.LocalPath)\config\filelist.txt" `
--publisher-name ".NET nanoFramework" `
--description "nanoFramework.nanoCLR.CLI" `
--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 nanoCLR assemblies
continueOnError: true
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], '')
)
- task: MSBuild@1
condition: succeeded()
displayName: Pack nanoCLR CLI
inputs:
solution: 'targets\netcore\nanoFramework.nanoCLR.CLI\nanoFramework.nanoCLR.CLI.csproj'
platform: "Any CPU"
msbuildArguments: "/p:PublicRelease=true /t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) "
configuration: "Release"
maximumCpuCount: true
- pwsh: |
.\sign code azure-key-vault `
"**/*.nupkg" `
--base-directory "$(Build.ArtifactStagingDirectory)" `
--file-list "$(Build.Repository.LocalPath)\config\filelist.txt" `
--publisher-name ".NET nanoFramework" `
--description "nanoFramework.nanoCLR.CLI NuGet" `
--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 packages
continueOnError: true
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], '')
)
- task: CopyFiles@2
condition: succeeded()
displayName: Copy nanoclr
inputs:
SourceFolder: '$(Build.Repository.LocalPath)\build\bin\Release'
Contents: "nanoFramework.nanoCLR.dll"
TargetFolder: "$(Build.ArtifactStagingDirectory)/nanoclr"
- task: PublishPipelineArtifact@1
condition: succeeded()
displayName: Publish nanoclr
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/nanoclr"
artifactName: nanoclr_cli
artifactType: pipeline