Repository navigation
348 lines (306 loc) · 11.9 KB
/
Copy pathpublish.yml
File metadata and controls
348 lines (306 loc) · 11.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
name: Publish
# Release publishing is intentionally GitHub Actions only.
# Maintainers create a v* tag or run workflow_dispatch; local machines may build
# test packages, but they are not the release authority.
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version, for example 1.0.6"
required: true
type: string
permissions:
contents: write
env:
DOTNET_NOLOGO: "true"
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "true"
CONFIGURATION: Release
SOLUTION: AndroidTreeView.sln
jobs:
resolve:
name: Resolve release version
runs-on: windows-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Resolve release version
id: version
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
if ('${{ github.event_name }}' -eq 'workflow_dispatch') {
$version = '${{ inputs.version }}'.Trim().TrimStart('v')
$tag = "v$version"
} else {
$tag = '${{ github.ref_name }}'
$version = $tag.Trim().TrimStart('v')
}
if ($version -notmatch '^\d+\.\d+\.\d+$') {
throw "Release version '$version' must be major.minor.patch."
}
"tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
Write-Host "Publishing $tag as version $version."
validate:
name: Validate on Windows
runs-on: windows-latest
needs: resolve
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Restore
run: dotnet restore $env:SOLUTION
- name: Build
run: dotnet build $env:SOLUTION -c $env:CONFIGURATION --no-restore
- name: Test
run: >-
dotnet test $env:SOLUTION
-c $env:CONFIGURATION
--no-build
--logger trx
--results-directory test-results
- name: Verify scrcpy release pin
shell: pwsh
run: ./tools/verify-scrcpy-latest.ps1
- name: Verify Root tool release pins
shell: pwsh
run: ./tools/verify-roottools-latest.ps1
package:
name: Package ${{ matrix.product }} ${{ matrix.rid }}
runs-on: ${{ matrix.os }}
needs:
- resolve
- validate
strategy:
fail-fast: false
matrix:
include:
- product: App
rid: win-x64
os: windows-latest
artifact: android-tree-view-app-win-x64
- product: App
rid: osx-arm64
os: macos-latest
artifact: android-tree-view-app-osx-arm64
- product: Mini
rid: win-x64
os: windows-latest
artifact: android-tree-view-mini-win-x64
- product: Mini
rid: osx-arm64
os: macos-latest
artifact: android-tree-view-mini-osx-arm64
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Build ZIP
shell: pwsh
run: >-
./packaging/build-update-zip.ps1
-Product ${{ matrix.product }}
-Rid ${{ matrix.rid }}
-Configuration $env:CONFIGURATION
-Version ${{ needs.resolve.outputs.version }}
- name: Verify macOS app bundle ZIP
if: matrix.rid == 'osx-arm64'
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$zip = Get-ChildItem -Path artifacts -Filter '*.zip' | Select-Object -First 1
if ($null -eq $zip) {
throw 'No ZIP artifact was produced.'
}
$product = '${{ matrix.product }}'
$appName = if ($product -eq 'Mini') { 'AndroidTreeView Mini.app' } else { 'AndroidTreeView.app' }
$executable = if ($product -eq 'Mini') { 'AndroidTreeView.App.mini' } else { 'AndroidTreeView.App' }
$entries = & unzip -Z1 $zip.FullName
if ($LASTEXITCODE -ne 0) {
throw "Could not inspect '$($zip.FullName)' with unzip."
}
$requiredEntries = @(
"$appName/Contents/Info.plist",
"$appName/Contents/MacOS/$executable",
"$appName/Contents/MacOS/release.json",
"$appName/Contents/MacOS/scrcpy/scrcpy",
"$appName/Contents/MacOS/scrcpy/adb"
)
foreach ($entry in $requiredEntries) {
if ($entries -notcontains $entry) {
throw "macOS ZIP '$($zip.Name)' is missing required entry '$entry'."
}
}
$looseRootEntries = @('release.json', $executable) | Where-Object { $entries -contains $_ }
if ($looseRootEntries) {
throw "macOS ZIP '$($zip.Name)' contains loose root entries instead of only an .app bundle: $($looseRootEntries -join ', ')."
}
Write-Host "Verified macOS ZIP contains $appName."
- name: Verify package integrity and Root tools isolation
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = Get-ChildItem -Path artifacts -Filter '*.zip' | Select-Object -First 1
if ($null -eq $zip) {
throw 'No ZIP artifact was produced.'
}
$sidecarPath = "$($zip.FullName).sha256"
if (-not (Test-Path -LiteralPath $sidecarPath)) {
throw "ZIP '$($zip.Name)' is missing its SHA-256 sidecar."
}
$sidecar = (Get-Content -LiteralPath $sidecarPath -Raw).Trim()
if ($sidecar -notmatch '^([0-9a-fA-F]{64}) \*([^\\/\r\n]+)$') {
throw "SHA-256 sidecar for '$($zip.Name)' has an invalid format."
}
$expectedHash = $Matches[1].ToLowerInvariant()
$expectedName = $Matches[2]
$actualHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $zip.FullName).Hash.ToLowerInvariant()
if ($expectedName -ne $zip.Name -or $expectedHash -ne $actualHash) {
throw "SHA-256 sidecar does not match ZIP '$($zip.Name)'."
}
$product = '${{ matrix.product }}'
$rid = '${{ matrix.rid }}'
$appPrefix = if ($rid -eq 'osx-arm64') { 'AndroidTreeView.app/Contents/MacOS/' } else { '' }
$archive = [System.IO.Compression.ZipFile]::OpenRead($zip.FullName)
try {
$entries = @($archive.Entries | ForEach-Object { $_.FullName })
} finally {
$archive.Dispose()
}
if ($rid -eq 'win-x64') {
$executable = if ($product -eq 'Mini') { 'AndroidTreeView.App.mini.exe' } else { 'AndroidTreeView.App.exe' }
$requiredWindowsEntries = @(
$executable,
'release.json',
'scrcpy/scrcpy.exe',
'scrcpy/adb.exe'
)
foreach ($entry in $requiredWindowsEntries) {
if ($entries -notcontains $entry) {
throw "Windows ZIP '$($zip.Name)' is missing required entry '$entry'."
}
}
}
$rootEntries = @($entries | Where-Object { $_ -match '(^|/)root-tools/' })
if ($product -eq 'Mini') {
if ($rootEntries.Count -ne 0) {
throw "Mini ZIP '$($zip.Name)' contains App-only Root tools: $($rootEntries -join ', ')."
}
Write-Host "Verified Mini ZIP does not contain root-tools/."
exit 0
}
$payloadExecutable = if ($rid -eq 'win-x64') { 'payload-dumper-go.exe' } else { 'payload-dumper-go' }
$fastbootExecutable = if ($rid -eq 'win-x64') { 'fastboot.exe' } else { 'fastboot' }
$requiredEntries = @(
"${appPrefix}scrcpy/$fastbootExecutable",
"${appPrefix}root-tools/magisk/Magisk-v30.7.apk",
"${appPrefix}root-tools/payload-dumper/$payloadExecutable"
)
foreach ($entry in $requiredEntries) {
if ($entries -notcontains $entry) {
throw "App ZIP '$($zip.Name)' is missing required Root tool '$entry'."
}
}
if ($rid -eq 'osx-arm64') {
$extractDir = Join-Path $env:RUNNER_TEMP 'root-tools-mode-check'
New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
& unzip -q $zip.FullName -d $extractDir
if ($LASTEXITCODE -ne 0) {
throw "Could not extract '$($zip.FullName)' to verify executable mode."
}
$payloadPath = Join-Path $extractDir "${appPrefix}root-tools/payload-dumper/$payloadExecutable"
$mode = [System.IO.File]::GetUnixFileMode($payloadPath)
if (-not ($mode -band [System.IO.UnixFileMode]::UserExecute)) {
throw "macOS payload-dumper-go is not executable in '$($zip.Name)' (mode: $mode)."
}
}
Write-Host "Verified App ZIP contains fastboot, Magisk, and payload-dumper-go."
- name: Upload package artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: |
artifacts/*.zip
artifacts/*.zip.sha256
if-no-files-found: error
release:
name: Create GitHub Release
runs-on: windows-latest
needs:
- resolve
- package
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Download package artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
merge-multiple: true
- name: Generate checksum summary
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$artifactsDir = 'artifacts'
$sidecars = Get-ChildItem -Path $artifactsDir -Filter '*.zip.sha256' -ErrorAction Stop | Sort-Object Name
if ($sidecars.Count -ne 4) {
throw "Expected 4 .zip.sha256 files in '$artifactsDir', found $($sidecars.Count)."
}
$lines = foreach ($sidecar in $sidecars) {
(Get-Content -LiteralPath $sidecar.FullName -Raw).Trim()
}
Set-Content -Path (Join-Path $artifactsDir 'SHA256SUMS.txt') -Value $lines -Encoding ascii
$lines | ForEach-Object { Write-Host $_ }
- name: Compose release notes
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$version = '${{ needs.resolve.outputs.version }}'
$checksums = (Get-Content -Path 'artifacts/SHA256SUMS.txt' -Raw).TrimEnd()
$lines = @(
"## AndroidTreeView $version"
''
'Release packages are GitHub Actions-built ZIP packages for Windows x64 and macOS Apple Silicon. macOS ZIPs contain top-level .app bundles.'
''
'### Artifacts'
''
"- AndroidTreeView-$version-win-x64.zip"
"- AndroidTreeView-$version-osx-arm64.zip"
"- AndroidTreeView-Mini-$version-win-x64.zip"
"- AndroidTreeView-Mini-$version-osx-arm64.zip"
''
'### SHA-256'
''
'```'
$checksums
'```'
)
Set-Content -Path 'RELEASE_NOTES.md' -Value $lines -Encoding utf8
Get-Content -Path 'RELEASE_NOTES.md' -Raw
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.resolve.outputs.tag }}
target_commitish: ${{ github.sha }}
name: AndroidTreeView ${{ needs.resolve.outputs.version }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: false
fail_on_unmatched_files: true
files: |
artifacts/*.zip
artifacts/*.zip.sha256
artifacts/SHA256SUMS.txt