-
-
Notifications
You must be signed in to change notification settings - Fork 515
622 lines (530 loc) · 18 KB
/
main.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
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
609
610
611
612
613
614
615
616
617
618
619
620
621
622
name: EarTrumpet
on:
push:
branches:
- master
- dev
- rafael/*
paths-ignore:
- '**/*.md'
- '.github/ISSUE_TEMPLATE/*'
- '.github/workflows/sponsors.yml'
- '.github/workflows/translators.yml'
- 'Graphics/*'
pull_request:
branches:
- dev
paths-ignore:
- '**/*.md'
- crowdin.yml
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
GHA_HASH_PATHS: |
EarTrumpet/**
!EarTrumpet/**/bin/**
!EarTrumpet/**/obj/**
!EarTrumpet/**/.vs/**
EarTrumpet.Package/**
!EarTrumpet.Package/**/bin/**
!EarTrumpet.Package/**/obj/**
!EarTrumpet/**/.vs/**
Packaging/**
jobs:
#
# Base build
#
base:
name: 🔨 Build Base
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check for existing base
uses: actions/cache/restore@v4
id: base-exists
with:
path: .artifacts
key: base-${{ hashFiles(env.GHA_HASH_PATHS) }}
lookup-only: true
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
includePrerelease: false
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Use GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Create artifacts folder
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path .artifacts/
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Generate versioning artifact
shell: pwsh
run: |
"${{ steps.gitversion.outputs.majorMinorPatch }}.${{ steps.gitversion.outputs.commitsSinceVersionSource }}" |
Out-File .artifacts/version_4.txt
"${{ steps.gitversion.outputs.majorMinorPatch }}.0" |
Out-File .artifacts/version_3.txt
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Restore packages
run: dotnet restore EarTrumpet.sln
shell: cmd
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Build EarTrumpet
shell: cmd
run: >
dotnet publish
/p:PublishProfile=x86
/p:Platform=x86
EarTrumpet\EarTrumpet.csproj
dotnet publish
/p:PublishProfile=x64
/p:Platform=x64
EarTrumpet\EarTrumpet.csproj
dotnet publish
/p:PublishProfile=arm64
/p:Platform=arm64
EarTrumpet\EarTrumpet.csproj
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Set Bugsnag API key
shell: pwsh
run: |
Get-ChildItem .artifacts\base\**\app.config | ForEach-Object {
$cfg = Get-Content $_
$cfg | ForEach-Object { $_.Replace("{bugsnag.apikey}", "${{ secrets.bugsnag_api_key }}") } | Set-Content $_
}
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Sign all files
uses: azure/[email protected]
with:
azure-tenant-id: ${{ secrets.azure_tenant_id }}
azure-client-id: ${{ secrets.azure_client_id }}
azure-client-secret: ${{ secrets.azure_client_secret }}
endpoint: https://wus2.codesigning.azure.net/
trusted-signing-account-name: main
certificate-profile-name: profileTWN
files-catalog: packaging\catalog.txt
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
if: steps.base-exists.outputs.cache-hit != 'true'
- name: Add to cache
uses: actions/cache/save@v4
with:
key: base-${{ hashFiles(env.GHA_HASH_PATHS) }}
path: .artifacts
if: steps.base-exists.outputs.cache-hit != 'true'
#
# Packaging: AppInstaller
#
appinstaller:
name: 📦 Package for AppInstaller
runs-on: windows-latest
needs: base
env:
channel: 'AppInstaller'
publisher: 'CN=File-New-Project, O=File-New-Project, L=Purcellville, S=Virginia, C=US'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Restore base
uses: actions/cache/restore@v4
with:
path: .artifacts
key: base-${{ hashFiles(env.GHA_HASH_PATHS) }}
fail-on-cache-miss: true
- name: Configure manifest
uses: ./.github/actions/configure-manifest
with:
manifest: EarTrumpet.Package/Package.appxmanifest
store-association: EarTrumpet.Package/Package.StoreAssociation.xml
publisher: ${{ env.publisher }}
branch: ${{ github.ref_name }}
prefix: 'EarTrumpet'
version: .artifacts/version_4.txt
- name: Set up MSBuild
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- name: Restore packages
shell: pwsh
run: >
dotnet restore
EarTrumpet.sln
- name: Create msixbundle
shell: pwsh
run: >
msbuild
/p:AppxBundle=Always
/p:AppxPackageSigningEnabled=false
/p:AppxPackageDir=..\.artifacts\sideload\
/p:AppxPackageTestDir=..\.artifacts\sideload\
/p:AppInstallerUri="https://install.eartrumpet.app"
/p:Configuration=Release
/p:Channel=AppInstaller
/p:GenerateAppInstallerFile=true
/p:Platform=x86
/p:UapAppxPackageBuildMode=SideloadOnly
/p:WapAlwaysBuildDependentProjects=false
"/p:AppxBundlePlatforms=x86|x64|arm64"
EarTrumpet.Package/EarTrumpet.Package.wapproj
- name: Stage AppInstaller manifest
shell: pwsh
run: >
Copy-Item Packaging\AppInstaller\EarTrumpet.Package.appinstaller .artifacts\sideload\
-Force
- name: Configure AppInstaller manifest
uses: ./.github/actions/configure-appinstaller
with:
manifest: .artifacts\sideload\EarTrumpet.Package.appinstaller
bundle: 'EarTrumpet.Package_*_x86_x64_arm64.msixbundle'
version: .artifacts/version_4.txt
branch: ${{ github.ref_name }}
- name: Sign package
uses: azure/[email protected]
with:
azure-tenant-id: ${{ secrets.azure_tenant_id }}
azure-client-id: ${{ secrets.azure_client_id }}
azure-client-secret: ${{ secrets.azure_client_secret }}
endpoint: https://wus2.codesigning.azure.net/
trusted-signing-account-name: main
certificate-profile-name: profileTWN
files-folder: .artifacts/sideload/
files-folder-filter: msixbundle
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: AppInstaller
path: |
.artifacts/sideload/EarTrumpet.Package_*_x86_x64_arm64.msixbundle
.artifacts/sideload/EarTrumpet.Package.appinstaller
#
# Packaging: Chocolatey
#
chocolatey:
name: 📦 Package for Chocolatey
runs-on: windows-latest
needs: base
env:
channel: 'Chocolatey'
publisher: 'CN=File-New-Project, O=File-New-Project, L=Purcellville, S=Virginia, C=US'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore base
uses: actions/cache/restore@v4
with:
path: .artifacts
key: base-${{ hashFiles(env.GHA_HASH_PATHS) }}
fail-on-cache-miss: true
- name: Adjust nuspec
uses: ./.github/actions/configure-nuspec
with:
nuspec: Packaging\Chocolatey\eartrumpet.nuspec
version: .artifacts/version_4.txt
- name: Stage packaging
shell: pwsh
run: |
Copy-Item Packaging\Chocolatey -Recurse .artifacts
- name: Create release archive
shell: pwsh
run: >
Compress-Archive
-Path .artifacts\base\x86\**
-DestinationPath .artifacts\chocolatey\tools\release.zip
-CompressionLevel Optimal
- name: Create package
shell: pwsh
run: >
choco
pack ".artifacts\chocolatey\eartrumpet.nuspec"
--out ".artifacts\chocolatey"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Chocolatey
path: |
.artifacts/chocolatey/eartrumpet.*.nupkg
#
# Packaging: Store
#
store:
name: 📦 Package for Microsoft Store
runs-on: windows-latest
needs: base
env:
channel: 'Store'
publisher: 'CN=6099D0EF-9374-47ED-BDFE-A82136831235'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Restore base
uses: actions/cache/restore@v4
with:
path: .artifacts
key: base-${{ hashFiles(env.GHA_HASH_PATHS) }}
fail-on-cache-miss: true
- name: Configure manifest
uses: ./.github/actions/configure-manifest
with:
manifest: EarTrumpet.Package/Package.appxmanifest
store-association: EarTrumpet.Package/Package.StoreAssociation.xml
publisher: ${{ env.publisher }}
branch: ${{ github.ref_name }}
prefix: 'EarTrumpet'
version: .artifacts/version_3.txt
- name: Set up MSBuild
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- name: Restore packages
shell: pwsh
run: >
dotnet restore
EarTrumpet.sln
- name: Create msixbundle
shell: pwsh
run: >
msbuild
/p:AppxBundle=Always
/p:AppxPackageSigningEnabled=false
/p:AppxPackageDir=..\.artifacts\store\
/p:Configuration=Release
/p:Channel=Store
/p:GenerateAppInstallerFile=false
/p:Platform=x86
/p:UapAppxPackageBuildMode=CI
/p:WapAlwaysBuildDependentProjects=false
"/p:AppxBundlePlatforms=x86|x64|arm64"
EarTrumpet.Package/EarTrumpet.Package.wapproj
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: MicrosoftStore
path: |
.artifacts/store/EarTrumpet.Package_*_x86_x64_arm64.msixbundle
.artifacts/store/EarTrumpet.Package_*_x86_x64_arm64_bundle.msixupload
#
# Packaging: Loose
#
loose:
name: 📦 Package for Loose scenarios
runs-on: windows-latest
needs: base
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Restore base
uses: actions/cache/restore@v4
with:
path: .artifacts
key: base-${{ hashFiles(env.GHA_HASH_PATHS) }}
fail-on-cache-miss: true
- name: Create release archives
shell: pwsh
run: >
New-Item
-ItemType Directory
-Path .artifacts\loose
-Force
@("x86", "x64", "arm64") | ForEach-Object {
Compress-Archive `
-Path .artifacts\base\$_\* `
-DestinationPath .artifacts\loose\EarTrumpet_$(Get-Content .artifacts/version_4.txt)_$($_).zip `
-CompressionLevel Optimal
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Loose
path: |
.artifacts/loose/*.zip
#
# Deployment: AppInstaller
#
deploy-appinstaller:
name: 🚀 Deploy AppInstaller package
runs-on: windows-latest
needs: appinstaller
if: |
github.event_name != 'pull_request' &&
(
startsWith(github.ref, 'refs/heads/dev') ||
startsWith(github.ref, 'refs/heads/master') ||
startsWith(github.ref, 'refs/heads/feature') ||
startsWith(github.ref, 'refs/heads/rafael')
)
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: AppInstaller
path: .
- name: Log into Azure
uses: azure/login@v2
with:
creds: '{"clientId":"${{ secrets.azure_storage_client_id }}","clientSecret":"${{ secrets.azure_storage_client_secret }}","subscriptionId":"${{ secrets.azure_storage_subscription_id }}","tenantId":"${{ secrets.azure_tenant_id }}"}'
enable-AzPSSession: true
- name: Upload blob to Azure Storage
uses: azure/powershell@v2
with:
azPSVersion: 'latest'
inlineScript: >
$context =
New-AzStorageContext
-StorageAccountName eartrumpetstorage
-UseConnectedAccount
Get-ChildItem -File EarTrumpet.Package_*_x86_x64_arm64.msixbundle | ForEach-Object {
Set-AzStorageBlobContent `
-File $_.FullName `
-Container builds `
-Blob ('${{ github.ref_name }}/' + $_.Name) `
-Context $context `
-Properties @{ContentType = "application/msixbundle";} `
-Force
}
Set-AzStorageBlobContent
-File EarTrumpet.Package.appinstaller
-Blob '${{ github.ref_name }}/EarTrumpet.Package.appinstaller'
-Container builds
-Context $context
-Properties @{ContentType = "application/appinstaller";} `
-Force
#
# Deployment: Microsoft Store
#
deploy-store:
name: 🚀 Deploy Microsoft Store package
runs-on: windows-latest
needs: store
if: |
github.event_name != 'pull_request' &&
(
startsWith(github.ref, 'refs/heads/master')
)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: MicrosoftStore
path: .
- name: Push to Microsoft Store
shell: powershell
run: >
Set-PSRepository
-Name "PSGallery"
-InstallationPolicy Trusted
Install-Module
-Name StoreBroker
$Password = ConvertTo-SecureString '${{ secrets.partnercenter_client_secret }}'
-AsPlainText
-Force
$Credentials = New-Object System.Management.Automation.PSCredential ('${{ secrets.partnercenter_client_id }}', $Password)
Set-StoreBrokerAuthentication
-TenantId '${{ secrets.partnercenter_tenant_id }}'
-Credential $Credentials
-Verbose
$SubmissionRoot = "$env:Temp\Packaging\Submission"
$Bundle = Resolve-Path "EarTrumpet.Package_*_x86_x64_arm64_bundle.msixupload" | Split-Path -Leaf
New-SubmissionPackage
-ConfigPath "Packaging\MicrosoftStore\SBConfig.json"
-PDPRootPath "Packaging\MicrosoftStore\PDPs"
-ImagesRootPath "Packaging\MicrosoftStore\PDPs"
-AppxPath "$Bundle"
-MediaFallbackLanguage en-US
-OutPath "$SubmissionRoot"
-OutName EarTrumpet
-Verbose
$SubmissionId, $SubmissionUrl =
Update-ApplicationSubmission
-AppId 9NBLGGH516XP
-SubmissionDataPath "$SubmissionRoot\EarTrumpet.json"
-PackagePath "$SubmissionRoot\EarTrumpet.zip"
-AddPackages
-UpdateListings
-UpdatePublishModeAndVisibility
-UpdatePricingAndAvailability
-UpdateAppProperties
-UpdateNotesForCertification
-TargetPublishMode Manual
-Force
-Verbose
Complete-ApplicationSubmission
-AppId 9NBLGGH516XP
-SubmissionId $SubmissionId
-Verbose
#
# Deployment: GitHub
#
deploy-github:
name: 🚀 Deploy GitHub Release
runs-on: windows-latest
needs: loose
if: |
github.event_name != 'pull_request' &&
(
startsWith(github.ref, 'refs/heads/master')
)
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Restore base
uses: actions/cache/restore@v4
with:
path: .artifacts
key: base-${{ hashFiles(env.GHA_HASH_PATHS) }}
fail-on-cache-miss: true
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Loose
path: .artifacts/loose
- name: Generate changelog
id: changelog
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: >
$lastTagRef = git describe --match "[0-9]*.[0-9]*.[0-9]*.[0-9]*" --abbrev=0 --tags HEAD 2>$null
$lastTagDate = git show -s --format=%aI "$lastTagRef^{commit}"
$query = (Get-Content ".github/workflows/queries/commits.graphql" -Raw)
-replace '%%OWNER%%', '${{ github.repository_owner }}'
-replace '%%REPO%%', '${{ github.event.repository.name }}'
$template = Get-Content ".github/workflows/templates/commits.md" -Raw
$changelog = gh api graphql
--paginate
-F query="$query"
-F lastTagDate="$lastTagDate"
-F ref="HEAD"
--template "$template"
$changelog | Out-File -FilePath .artifacts/changelog.md
- name: Create Release
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
$version = Get-Content .artifacts/version_4.txt
gh release create "v$version"
--draft
--title "$version"
--notes-file .artifacts/changelog.md
(Get-ChildItem ".artifacts/loose/*.zip").FullName