Repository navigation
211 lines (205 loc) · 11.8 KB
/
Copy pathrelease.yml
File metadata and controls
211 lines (205 loc) · 11.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
name: Desktop build and publish
on:
workflow_dispatch:
inputs:
release_tag:
description: Existing release tag to update (the tag is not moved)
required: true
default: v1.0.4-test.20261019
runtime:
description: Desktop platform (Mac supports Apple Silicon only)
type: choice
options: [all, win-x64, win-arm64, osx-arm64]
default: all
replace_existing:
description: Replace selected existing installers (other platforms are preserved)
type: boolean
default: false
validation_only:
description: Run essential release checks without packaging or publishing
type: boolean
default: false
push:
tags: ['v*']
permissions:
contents: read
concurrency:
group: release-${{ inputs.release_tag || github.ref_name }}
cancel-in-progress: false
jobs:
plan:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.plan.outputs.tag }}
runtimes: ${{ steps.plan.outputs.runtimes }}
test_package: ${{ steps.plan.outputs.test_package }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- id: plan
name: Validate version, tag and architecture
shell: pwsh
env:
REQUESTED_TAG: ${{ inputs.release_tag }}
REQUESTED_RUNTIME: ${{ inputs.runtime }}
run: |
$version = ./scripts/get-product-version.ps1
$tag = if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch') { $env:REQUESTED_TAG } else { $env:GITHUB_REF_NAME }
$test = $tag -cmatch ('^v' + [regex]::Escape($version) + '-test\.[0-9]{8}$')
if (-not $test -and $tag -cne "v$version") { throw 'Tag and ProductVersion.props differ.' }
$runtimes = if ($env:GITHUB_EVENT_NAME -eq 'workflow_dispatch' -and $env:REQUESTED_RUNTIME -ne 'all') { @($env:REQUESTED_RUNTIME) } else { @('win-x64', 'win-arm64', 'osx-arm64') }
foreach ($runtime in $runtimes) { if ($runtime -notin @('win-x64', 'win-arm64', 'osx-arm64')) { throw 'Unsupported architecture.' } }
"tag=$tag" >> $env:GITHUB_OUTPUT
"runtimes=$($runtimes | ConvertTo-Json -Compress -AsArray)" >> $env:GITHUB_OUTPUT
"test_package=$($test.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT
package:
needs: plan
runs-on: ${{ matrix.runtime == 'osx-arm64' && 'macos-15' || 'windows-latest' }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
runtime: ${{ fromJSON(needs.plan.outputs.runtimes) }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
with:
global-json-file: global.json
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore and build the complete product
shell: pwsh
run: |
dotnet restore OpticalSystemDesign.slnx --locked-mode
if ($LASTEXITCODE) { exit $LASTEXITCODE }
dotnet build OpticalSystemDesign.slnx -c Release --no-restore /m:1 /nr:false -p:ContinuousIntegrationBuild=true
if ($LASTEXITCODE) { exit $LASTEXITCODE }
- name: Verify release and installation boundaries
if: matrix.runtime != 'osx-arm64'
shell: pwsh
run: |
./scripts/test-ota-key-crypto.ps1
dotnet test tests/OpticalSystemDesign.Tests/OpticalSystemDesign.Tests.csproj -c Release --no-build --no-restore --filter 'FullyQualifiedName~ProductVersionInfoTests|FullyQualifiedName~ReleaseUpdateTests|FullyQualifiedName~OtaClientTests|FullyQualifiedName~OtaHelperRuntimeTests|FullyQualifiedName~WindowsInstallationGateTests|FullyQualifiedName~WindowsInstallationLifetimeTests|FullyQualifiedName~OtaShutdownGuardTests|FullyQualifiedName~WindowsPackagingTests|FullyQualifiedName~CloudReleaseTests|FullyQualifiedName~BuiltInModuleDeliveryTests|FullyQualifiedName~ProductDependencyArchitectureTests' --logger 'trx;LogFileName=release.trx' --results-directory artifacts/cloud-verification
if ($LASTEXITCODE) { exit $LASTEXITCODE }
- name: Verify Apple Silicon packaging and shared product boundaries
if: matrix.runtime == 'osx-arm64'
shell: pwsh
run: |
dotnet test tests/OpticalSystemDesign.Tests/OpticalSystemDesign.Tests.csproj -c Release --no-build --no-restore --filter 'FullyQualifiedName~ProductVersionInfoTests|FullyQualifiedName~CloudReleaseTests|FullyQualifiedName~MacPackagingTests|FullyQualifiedName~OtaClientTests|FullyQualifiedName~OtaShutdownGuardTests|FullyQualifiedName~BuiltInModuleDeliveryTests|FullyQualifiedName~ProductDependencyArchitectureTests' --logger 'trx;LogFileName=macos-release.trx' --results-directory artifacts/cloud-verification
if ($LASTEXITCODE) { exit $LASTEXITCODE }
- name: Build the complete self-contained EXE installer
if: ${{ matrix.runtime != 'osx-arm64' && !inputs.validation_only }}
shell: pwsh
env:
TARGET_RUNTIME: ${{ matrix.runtime }}
TEST_PACKAGE: ${{ needs.plan.outputs.test_package }}
run: |
$package = ./scripts/build-installer.ps1 -Runtime $env:TARGET_RUNTIME -UnsignedTestPackage:($env:TEST_PACKAGE -eq 'true') -PassThru
if ($env:TARGET_RUNTIME -eq 'win-x64') {
$payload = Get-ChildItem -LiteralPath (Join-Path $package.Directory 'payload') -Directory | Select-Object -First 1 -ExpandProperty FullName
./scripts/verify-built-in-package.ps1 -PublishDirectory $payload -OutputDirectory artifacts/cloud-package-verification
$env:OPTICAL_SYSTEM_DESIGN_OTA_RUNTIME_SOURCE = $payload
dotnet test tests/OpticalSystemDesign.Tests/OpticalSystemDesign.Tests.csproj -c Release --no-build --no-restore --filter 'FullyQualifiedName~OtaHelperRuntimeTests' --logger 'trx;LogFileName=ota-runtime-package.trx' --results-directory artifacts/cloud-verification
if ($LASTEXITCODE) { exit $LASTEXITCODE }
Remove-Item Env:OPTICAL_SYSTEM_DESIGN_OTA_RUNTIME_SOURCE
}
# Internal Actions handoff only. Publishing filters out these build records.
New-Item -ItemType Directory -Path distribution | Out-Null
Copy-Item -LiteralPath $package.Setup -Destination distribution
Copy-Item -LiteralPath (Join-Path $package.Directory 'release.json') -Destination "distribution/release-$env:TARGET_RUNTIME.json"
Get-FileHash -LiteralPath $package.Setup -Algorithm SHA256 | Format-List
- name: Build and verify the self-contained Apple Silicon DMG
if: ${{ matrix.runtime == 'osx-arm64' && !inputs.validation_only }}
shell: bash
env:
TEST_PACKAGE: ${{ needs.plan.outputs.test_package }}
run: |
options=()
if [[ "$TEST_PACKAGE" == true ]]; then options+=(--test-package); fi
bash scripts/build-macos.sh --output-root artifacts/cloud-macos "${options[@]}"
package_dir="$(find artifacts/cloud-macos -mindepth 1 -maxdepth 1 -type d -name 'package.*' ! -name '*.partial')"
test -n "$package_dir"
mkdir -p distribution artifacts/cloud-package-verification
cp "$package_dir"/*.dmg "$package_dir/release-osx-arm64.json" distribution/
cp "$package_dir/verification/"*.json artifacts/cloud-package-verification/
for report in "$package_dir/dmg-verification/"*.json; do
cp "$report" "artifacts/cloud-package-verification/dmg-$(basename "$report")"
done
shasum -a 256 distribution/*.dmg
- name: Verify Mac native replacement and relaunch using owned cloud bundles
if: ${{ matrix.runtime == 'osx-arm64' && !inputs.validation_only }}
shell: bash
run: |
package_dir="$(find artifacts/cloud-macos -mindepth 1 -maxdepth 1 -type d -name 'package.*' ! -name '*.partial')"
python3 scripts/test-macos-ota-install.py "$package_dir/image/Optical System Design.app" artifacts/cloud-macos/.dependencies artifacts/mac-ota-install-work
cp artifacts/mac-ota-install-work/summary.json artifacts/cloud-verification/mac-ota-install-summary.json
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: ${{ !inputs.validation_only }}
with:
name: cloud-package-${{ matrix.runtime }}
path: distribution/*
if-no-files-found: error
retention-days: 30
- name: Retain validation records inside Actions, not release attachments
if: ${{ always() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: cloud-checks-${{ matrix.runtime }}
path: |
artifacts/cloud-verification
artifacts/cloud-package-verification/*.json
if-no-files-found: warn
retention-days: 30
publish:
if: ${{ !inputs.validation_only }}
needs: [plan, package]
runs-on: macos-15
permissions:
contents: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
pattern: cloud-package-*
path: distribution
merge-multiple: true
- name: Prepare signed Mac archive and appcast before release mutation
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
OPTICAL_OTA_SIGNING_KEY: ${{ secrets.OPTICAL_OTA_SIGNING_KEY }}
OPTICAL_OTA_ENCRYPTED_BACKUP: ${{ secrets.OPTICAL_OTA_ENCRYPTED_BACKUP }}
OPTICAL_OTA_RECOVERY_PASSWORD: ${{ secrets.OPTICAL_OTA_RECOVERY_PASSWORD }}
RELEASE_TAG: ${{ needs.plan.outputs.tag }}
run: |
if (-not (Test-Path distribution/release-osx-arm64.json)) { return }
[void][IO.Directory]::CreateDirectory('distribution/release-evidence')
$headers = @{ Authorization = "Bearer $env:GH_TOKEN"; Accept = 'application/vnd.github+json'; 'User-Agent' = 'OpticalSystemDesign-MacOTA' }
$base = Invoke-RestMethod -Uri 'https://api.github.com/repos/VendettaMask/opticalsystem/contents/updates/macos/appcast.xml?ref=main' -Headers $headers
@{ sha = $base.sha } | ConvertTo-Json | Set-Content distribution/release-evidence/macos-feed-base.json -Encoding utf8
$feed = Join-Path $env:RUNNER_TEMP 'macos-feed-before.xml'
[IO.File]::WriteAllBytes($feed, [Convert]::FromBase64String($base.content))
./scripts/prepare-macos-ota-release.ps1 -DistributionDirectory distribution -Tag $env:RELEASE_TAG -ExistingFeed $feed -OutputDirectory distribution/release-evidence
- name: Verify and publish EXE and Apple Silicon DMG installers
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
OPTICAL_OTA_SIGNING_KEY: ${{ secrets.OPTICAL_OTA_SIGNING_KEY }}
OPTICAL_OTA_ENCRYPTED_BACKUP: ${{ secrets.OPTICAL_OTA_ENCRYPTED_BACKUP }}
OPTICAL_OTA_RECOVERY_PASSWORD: ${{ secrets.OPTICAL_OTA_RECOVERY_PASSWORD }}
RELEASE_TAG: ${{ needs.plan.outputs.tag }}
REPLACE_EXISTING: ${{ inputs.replace_existing || false }}
run: |
./scripts/publish-github-exe.ps1 -Repository $env:GITHUB_REPOSITORY -Tag $env:RELEASE_TAG -DistributionDirectory distribution -ReplaceExisting:($env:REPLACE_EXISTING -eq 'true') -NotesFile packaging/windows/RELEASE_NOTES.md
- name: Activate signed Mac OTA feed after published archive verification
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: ./scripts/publish-macos-appcast.ps1 -DistributionDirectory distribution
- name: Retain replacement receipts and previous assets inside Actions
if: ${{ always() }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: cloud-release-receipt
path: distribution/release-evidence
if-no-files-found: warn
retention-days: 30