-
Notifications
You must be signed in to change notification settings - Fork 35
608 lines (531 loc) · 19.9 KB
/
Copy pathpackage.yml
File metadata and controls
608 lines (531 loc) · 19.9 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
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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
name: Package
on:
pull_request:
branches: [ main ]
paths:
- '.github/workflows/package.yml'
- 'nuget/**'
- 'scripts/nuget/**'
- 'CMakeLists.txt'
- 'LICENSE'
- 'README.md'
- 'build.bat'
- 'build_all.bat'
- 'cmake/**'
- 'docs/**'
- 'include/**'
- 'src/**'
- 'test/**'
push:
branches: [ main ]
tags:
- 'v*'
paths:
- '.github/workflows/package.yml'
- 'nuget/**'
- 'scripts/nuget/**'
- 'CMakeLists.txt'
- 'LICENSE'
- 'README.md'
- 'build.bat'
- 'build_all.bat'
- 'cmake/**'
- 'docs/**'
- 'include/**'
- 'src/**'
- 'test/**'
workflow_dispatch:
inputs:
package_version:
description: Optional package version override
required: false
type: string
publish:
description: Publish the generated package to nuget.org
required: true
type: boolean
default: false
github_release:
description: Upload release assets to GitHub Releases
required: true
type: boolean
default: false
permissions:
contents: read
env:
CRTSYS_WINDOWS_SDK_VERSION: 10.0.22621.0
jobs:
version:
name: Resolve package version
runs-on: windows-2022
outputs:
package_version: ${{ steps.version.outputs.package_version }}
steps:
- uses: actions/checkout@v5
- name: Resolve package version
id: version
shell: pwsh
run: |
$version = '${{ inputs.package_version }}'
if ([string]::IsNullOrWhiteSpace($version)) {
$version = ./scripts/nuget/Get-CrtSysVersion.ps1
}
if ($env:GITHUB_REF_TYPE -eq 'tag') {
if ($env:GITHUB_REF_NAME -notmatch '^v(.+)$') {
throw "Release tag must use v<version> format."
}
$tagVersion = $Matches[1]
if ($version -ne $tagVersion) {
throw "Package version '$version' does not match tag version '$tagVersion'."
}
}
"package_version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
Write-Host "Package version: $version"
build-libs:
name: Build NuGet libs ${{ matrix.vs_label }} ${{ matrix.toolset }} ${{ matrix.arch }} ${{ matrix.config }}
needs: version
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
toolset: [v142, v143, v145]
arch: [x86, x64, ARM, ARM64]
config: [Debug, Release]
include:
- toolset: v142
vs_label: VS2019
runner: windows-2022
windows_sdk: 10.0.22621.0
- toolset: v143
vs_label: VS2022
runner: windows-2022
windows_sdk: 10.0.22621.0
- toolset: v145
vs_label: VS2026
runner: windows-2025-vs2026
windows_sdk: 10.0.26100.0
exclude:
- toolset: v145
arch: ARM
steps:
- uses: actions/checkout@v5
- name: Ensure WDK
if: ${{ matrix.toolset == 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}'
- name: Ensure WDK for x86
if: ${{ matrix.arch == 'x86' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ env.CRTSYS_WINDOWS_SDK_VERSION }}' -RequiredPlatforms x86
- name: Ensure WDK for ARM32
if: ${{ matrix.arch == 'ARM' && matrix.toolset != 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}' -RequiredPlatforms ARM
- name: Ensure WDK for ARM64 old toolsets
if: ${{ matrix.arch == 'ARM64' && matrix.toolset != 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}' -RequiredPlatforms ARM64
- name: Build prebuilt libraries
shell: pwsh
run: |
$windowsSdkVersion = '${{ matrix.windows_sdk }}'
$wdkVersion = ''
if ('${{ matrix.toolset }}' -eq 'v145' -and '${{ matrix.arch }}' -eq 'x86') {
$wdkVersion = '${{ env.CRTSYS_WINDOWS_SDK_VERSION }}'
}
$parameters = @{
Toolset = '${{ matrix.toolset }}'
Architecture = '${{ matrix.arch }}'
Configuration = '${{ matrix.config }}'
WindowsSdkVersion = $windowsSdkVersion
}
if (-not [string]::IsNullOrWhiteSpace($wdkVersion)) {
$parameters.WdkVersion = $wdkVersion
}
./scripts/nuget/Build-CrtSysNuGetLibs.ps1 @parameters
- uses: actions/upload-artifact@v7
with:
name: crtsys-nuget-libs-${{ matrix.toolset }}-${{ matrix.arch }}-${{ matrix.config }}
path: artifacts/nuget-staging/lib/native/${{ matrix.toolset }}/${{ matrix.arch }}/${{ matrix.config }}
if-no-files-found: error
pack:
name: Pack NuGet
needs: [version, build-libs]
runs-on: windows-2022
outputs:
package_version: ${{ steps.version.outputs.package_version }}
steps:
- uses: actions/checkout@v5
- name: Set package version
id: version
shell: pwsh
run: |
"package_version=${{ needs.version.outputs.package_version }}" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- uses: NuGet/setup-nuget@v2
- uses: actions/download-artifact@v7
with:
pattern: crtsys-nuget-libs-*
path: artifacts/downloaded-libs
- name: Stage downloaded prebuilt libraries
shell: pwsh
run: |
$downloadRoot = Resolve-Path artifacts/downloaded-libs
foreach ($artifact in Get-ChildItem -Path $downloadRoot -Directory) {
if ($artifact.Name -notmatch '^crtsys-nuget-libs-(v[0-9]+)-(.+)-(Debug|Release)$') {
throw "Unexpected prebuilt library artifact name: $($artifact.Name)"
}
$toolset = $Matches[1]
$arch = $Matches[2]
$config = $Matches[3]
$destination = Join-Path 'artifacts/nuget-staging/lib/native' "$toolset/$arch/$config"
New-Item -ItemType Directory -Force -Path $destination | Out-Null
Copy-Item -Path (Join-Path $artifact.FullName '*') -Destination $destination -Recurse -Force
}
- name: Pack
shell: pwsh
run: ./scripts/nuget/Pack-CrtSysNuGet.ps1 -Version '${{ steps.version.outputs.package_version }}' -Toolset v142,v143,v145
- name: Pack GitHub release assets
shell: pwsh
run: ./scripts/nuget/Pack-CrtSysReleaseAssets.ps1 -Version '${{ steps.version.outputs.package_version }}' -Toolset v142,v143,v145
- uses: actions/upload-artifact@v7
with:
name: crtsys-nuget-${{ steps.version.outputs.package_version }}
path: artifacts/nuget/*.nupkg
if-no-files-found: error
- uses: actions/upload-artifact@v7
with:
name: crtsys-release-assets-${{ steps.version.outputs.package_version }}
path: artifacts/release/*
if-no-files-found: error
test-package-driver:
name: Test NuGet driver package ${{ matrix.vs_label }} ${{ matrix.toolset }} ${{ matrix.arch }} ${{ matrix.config }}
needs: pack
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
toolset: [v142, v143, v145]
arch: [x64, ARM, ARM64]
config: [Debug, Release]
include:
- toolset: v142
vs_label: VS2019
runner: windows-2022
windows_sdk: 10.0.22621.0
vs_major: 17
- toolset: v143
vs_label: VS2022
runner: windows-2022
windows_sdk: 10.0.22621.0
vs_major: 17
- toolset: v145
vs_label: VS2026
runner: windows-2025-vs2026
windows_sdk: 10.0.26100.0
vs_major: 18
exclude:
- toolset: v145
arch: ARM
steps:
- uses: actions/checkout@v5
- uses: NuGet/setup-nuget@v2
- name: Ensure WDK
if: ${{ matrix.toolset == 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}'
- name: Ensure WDK for ARM32
if: ${{ matrix.arch == 'ARM' && matrix.toolset != 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}' -RequiredPlatforms ARM
- name: Ensure WDK for ARM64 old toolsets
if: ${{ matrix.arch == 'ARM64' && matrix.toolset != 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}' -RequiredPlatforms ARM64
- uses: actions/download-artifact@v7
with:
name: crtsys-nuget-${{ needs.pack.outputs.package_version }}
path: artifacts/nuget
- name: Build package consumer test driver
shell: pwsh
run: >
./scripts/nuget/Test-CrtSysNuGetMsBuildPackage.ps1
-PackageDirectory artifacts/nuget
-Version '${{ needs.pack.outputs.package_version }}'
-Toolset '${{ matrix.toolset }}'
-Architecture '${{ matrix.arch }}'
-Configuration '${{ matrix.config }}'
-WindowsSdkVersion '${{ matrix.windows_sdk }}'
-VisualStudioMajorVersion '${{ matrix.vs_major }}'
test-package-layout:
name: Validate NuGet package layout ${{ matrix.vs_label }} ${{ matrix.toolset }} ${{ matrix.arch }} ${{ matrix.config }}
needs: pack
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
toolset: [v142, v143, v145]
arch: [x86, ARM]
config: [Debug, Release]
include:
- toolset: v142
vs_label: VS2019
- toolset: v143
vs_label: VS2022
- toolset: v145
vs_label: VS2026
exclude:
- toolset: v145
arch: ARM
steps:
- uses: actions/checkout@v5
- uses: NuGet/setup-nuget@v2
- uses: actions/download-artifact@v7
with:
name: crtsys-nuget-${{ needs.pack.outputs.package_version }}
path: artifacts/nuget
- name: Validate package layout
shell: pwsh
run: >
./scripts/nuget/Test-CrtSysNuGetPackage.ps1
-PackageDirectory artifacts/nuget
-Version '${{ needs.pack.outputs.package_version }}'
-Consumer Driver
-Toolset '${{ matrix.toolset }}'
-Architecture '${{ matrix.arch }}'
-Configuration '${{ matrix.config }}'
-SkipDriverBuild
test-package-app:
name: Test NuGet app package ${{ matrix.vs_label }} ${{ matrix.toolset }} ${{ matrix.arch }} ${{ matrix.config }}
needs: pack
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
toolset: [v142, v143, v145]
arch: [x86, x64, ARM, ARM64]
config: [Debug, Release]
include:
- toolset: v142
vs_label: VS2019
runner: windows-2022
windows_sdk: 10.0.22621.0
vs_major: 17
- toolset: v143
vs_label: VS2022
runner: windows-2022
windows_sdk: 10.0.22621.0
vs_major: 17
- toolset: v145
vs_label: VS2026
runner: windows-2025-vs2026
windows_sdk: 10.0.26100.0
vs_major: 18
exclude:
- toolset: v145
arch: ARM
steps:
- uses: actions/checkout@v5
- uses: NuGet/setup-nuget@v2
- uses: actions/download-artifact@v7
with:
name: crtsys-nuget-${{ needs.pack.outputs.package_version }}
path: artifacts/nuget
- name: Build package app consumer test
shell: pwsh
run: >
./scripts/nuget/Test-CrtSysNuGetPackage.ps1
-PackageDirectory artifacts/nuget
-Version '${{ needs.pack.outputs.package_version }}'
-Consumer App
-Toolset '${{ matrix.toolset }}'
-Architecture '${{ matrix.arch }}'
-Configuration '${{ matrix.config }}'
-WindowsSdkVersion '${{ matrix.windows_sdk }}'
-VisualStudioMajorVersion '${{ matrix.vs_major }}'
test-release-prebuilt-cmake:
name: Test release prebuilt CMake asset ${{ matrix.vs_label }} ${{ matrix.toolset }} ${{ matrix.arch }} ${{ matrix.config }}
needs: pack
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
toolset: [v142, v143, v145]
arch: [x86, x64, ARM, ARM64]
config: [Debug, Release]
include:
- toolset: v142
vs_label: VS2019
runner: windows-2022
windows_sdk: 10.0.22621.0
- toolset: v143
vs_label: VS2022
runner: windows-2022
windows_sdk: 10.0.22621.0
- toolset: v145
vs_label: VS2026
runner: windows-2025-vs2026
windows_sdk: 10.0.26100.0
exclude:
- toolset: v145
arch: ARM
steps:
- uses: actions/checkout@v5
- name: Ensure WDK
if: ${{ matrix.toolset == 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}'
- name: Ensure WDK for x86
if: ${{ matrix.arch == 'x86' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ env.CRTSYS_WINDOWS_SDK_VERSION }}' -RequiredPlatforms x86
- name: Ensure WDK for ARM32
if: ${{ matrix.arch == 'ARM' && matrix.toolset != 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}' -RequiredPlatforms ARM
- name: Ensure WDK for ARM64 old toolsets
if: ${{ matrix.arch == 'ARM64' && matrix.toolset != 'v145' }}
shell: pwsh
run: ./scripts/nuget/Ensure-CrtSysWdk.ps1 -WindowsSdkVersion '${{ matrix.windows_sdk }}' -RequiredPlatforms ARM64
- uses: actions/download-artifact@v7
with:
name: crtsys-release-assets-${{ needs.pack.outputs.package_version }}
path: artifacts/release
- name: Build prebuilt release CMake consumer test
shell: pwsh
run: |
$windowsSdkVersion = '${{ matrix.windows_sdk }}'
$wdkVersion = ''
if ('${{ matrix.arch }}' -eq 'x86') {
$wdkVersion = '${{ env.CRTSYS_WINDOWS_SDK_VERSION }}'
}
$parameters = @{
ReleaseDirectory = 'artifacts/release'
Version = '${{ needs.pack.outputs.package_version }}'
Toolset = '${{ matrix.toolset }}'
Architecture = '${{ matrix.arch }}'
Configuration = '${{ matrix.config }}'
WindowsSdkVersion = $windowsSdkVersion
}
if (-not [string]::IsNullOrWhiteSpace($wdkVersion)) {
$parameters.WdkVersion = $wdkVersion
}
./scripts/nuget/Test-CrtSysReleaseAssets.ps1 @parameters
test-release-prebuilt-layout:
name: Validate release prebuilt layout ${{ matrix.vs_label }} ${{ matrix.toolset }} ${{ matrix.arch }} ${{ matrix.config }}
needs: pack
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
toolset: [v142, v143, v145]
arch: [x86, ARM]
config: [Debug, Release]
include:
- toolset: v142
vs_label: VS2019
- toolset: v143
vs_label: VS2022
- toolset: v145
vs_label: VS2026
exclude:
- toolset: v145
arch: ARM
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v7
with:
name: crtsys-release-assets-${{ needs.pack.outputs.package_version }}
path: artifacts/release
- name: Validate prebuilt release layout
shell: pwsh
run: >
./scripts/nuget/Test-CrtSysReleaseAssets.ps1
-ReleaseDirectory artifacts/release
-Version '${{ needs.pack.outputs.package_version }}'
-Toolset '${{ matrix.toolset }}'
-Architecture '${{ matrix.arch }}'
-Configuration '${{ matrix.config }}'
-SkipDriverBuild
publish:
name: Publish NuGet
needs: [pack, test-package-driver, test-package-layout, test-package-app]
if: ${{ (github.event_name != 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.publish) }}
runs-on: windows-2022
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- uses: actions/download-artifact@v7
with:
name: crtsys-nuget-${{ needs.pack.outputs.package_version }}
path: artifacts/nuget
- name: Validate NuGet trusted publishing user
shell: pwsh
run: |
if ([string]::IsNullOrWhiteSpace('${{ vars.NUGET_TRUSTED_PUBLISHING_USER }}')) {
throw 'Repository variable NUGET_TRUSTED_PUBLISHING_USER is required for NuGet Trusted Publishing.'
}
- name: NuGet login
uses: NuGet/login@v1
id: nuget-login
with:
user: ${{ vars.NUGET_TRUSTED_PUBLISHING_USER }}
- name: Publish to nuget.org
shell: pwsh
env:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: ./scripts/nuget/Push-CrtSysNuGet.ps1 -SkipDuplicate
github-release:
name: Upload GitHub Release Assets
needs: [pack, test-package-driver, test-package-layout, test-package-app, test-release-prebuilt-cmake, test-release-prebuilt-layout]
if: ${{ (github.event_name != 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.github_release) }}
runs-on: windows-2022
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v7
with:
name: crtsys-release-assets-${{ needs.pack.outputs.package_version }}
path: artifacts/release
- name: Create or update GitHub release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
Set-Location '${{ github.workspace }}'
$version = '${{ needs.pack.outputs.package_version }}'
$tagName = "v$version"
if ('${{ github.ref_type }}' -eq 'tag') {
$tagName = '${{ github.ref_name }}'
}
$repo = '${{ github.repository }}'
$assets = @(Get-ChildItem -Path artifacts\release -File | Sort-Object FullName | ForEach-Object { $_.FullName })
if ($assets.Count -eq 0) {
throw 'No GitHub Release assets were found.'
}
& gh release view $tagName --repo $repo *> $null
if ($LASTEXITCODE -eq 0) {
Write-Host "Uploading assets to existing GitHub Release $tagName"
& gh release upload $tagName @assets --repo $repo --clobber
} else {
Write-Host "Creating GitHub Release $tagName"
$notes = @(
"crtsys $version release assets."
""
"- crtsys.$version.nupkg: offline NuGet package"
"- crtsys-$version-prebuilt.zip: headers, docs, CMake helpers/package config, native MSBuild imports, and toolset-specific prebuilt libraries (v142/v143 for x86/x64/ARM/ARM64 and v145 for x86/x64/ARM64)"
"- crtsys-$version-SHA256SUMS.txt: SHA-256 checksums"
) -join [Environment]::NewLine
& gh release create $tagName @assets --repo $repo --target '${{ github.sha }}' --title "crtsys $version" --notes $notes
}
if ($LASTEXITCODE -ne 0) {
throw "GitHub Release upload failed with exit code $LASTEXITCODE."
}