Skip to content

Commit c21e6f9

Browse files
Validate release zip artifacts in CI
1 parent fbb48a2 commit c21e6f9

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ jobs:
271271
272272
# Installer is created in output during the previous step
273273
274+
- name: Validate release zip
275+
shell: pwsh
276+
run: |
277+
$Platform = '${{ matrix.platform }}'
278+
.\scripts\verify-release-zip.ps1 -ZipPath "$PWD/output/UniGetUI.$Platform.zip" -FailOnUnexpectedFiles
279+
274280
- name: Code-sign installer
275281
if: ${{ fromJSON(needs.preflight.outputs.dry-run) == false }}
276282
shell: pwsh

scripts/build.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ $ZipPath = Join-Path $OutputPath "UniGetUI.$Platform.zip"
109109
Write-Host "`n=== Creating zip: $ZipPath ===" -ForegroundColor Cyan
110110
Compress-Archive -Path (Join-Path $BinDir "*") -DestinationPath $ZipPath -CompressionLevel Optimal
111111

112+
Write-Host "`n=== Validating release zip ===" -ForegroundColor Cyan
113+
& (Join-Path $PSScriptRoot "verify-release-zip.ps1") -ZipPath $ZipPath -FailOnUnexpectedFiles
114+
112115
# --- Installer (Inno Setup) ---
113116
if (-not $SkipInstaller) {
114117
$IsccPath = $null

scripts/verify-release-zip.ps1

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env pwsh
2+
<#
3+
.SYNOPSIS
4+
Extracts a release zip and validates its packaged IntegrityTree.json.
5+
6+
.PARAMETER ZipPath
7+
Path to the release zip to validate.
8+
9+
.PARAMETER FailOnUnexpectedFiles
10+
Fail validation if extracted files exist outside IntegrityTree.json.
11+
#>
12+
13+
[CmdletBinding()]
14+
param(
15+
[Parameter(Mandatory, Position = 0)]
16+
[string] $ZipPath,
17+
18+
[switch] $FailOnUnexpectedFiles
19+
)
20+
21+
$ErrorActionPreference = 'Stop'
22+
23+
if (-not (Test-Path $ZipPath -PathType Leaf)) {
24+
throw "The zip file '$ZipPath' does not exist."
25+
}
26+
27+
$ZipPath = (Resolve-Path $ZipPath).Path
28+
$TreeValidatorPath = Join-Path $PSScriptRoot 'verify-integrity-tree.ps1'
29+
if (-not (Test-Path $TreeValidatorPath -PathType Leaf)) {
30+
throw "Integrity validator not found at '$TreeValidatorPath'."
31+
}
32+
33+
$TempExtractPath = Join-Path ([System.IO.Path]::GetTempPath()) ("unigetui-zip-verify-" + [guid]::NewGuid())
34+
New-Item $TempExtractPath -ItemType Directory | Out-Null
35+
36+
try {
37+
Expand-Archive -Path $ZipPath -DestinationPath $TempExtractPath -Force
38+
39+
$ValidationPath = $TempExtractPath
40+
if (-not (Test-Path (Join-Path $ValidationPath 'IntegrityTree.json') -PathType Leaf)) {
41+
$CandidateDirectories = @(Get-ChildItem $TempExtractPath -Directory | Where-Object {
42+
Test-Path (Join-Path $_.FullName 'IntegrityTree.json') -PathType Leaf
43+
})
44+
45+
if ($CandidateDirectories.Count -ne 1) {
46+
throw "Could not locate IntegrityTree.json after extracting '$ZipPath'."
47+
}
48+
49+
$ValidationPath = $CandidateDirectories[0].FullName
50+
}
51+
52+
$ValidationParameters = @{ Path = $ValidationPath }
53+
if ($FailOnUnexpectedFiles) {
54+
$ValidationParameters.FailOnUnexpectedFiles = $true
55+
}
56+
57+
& $TreeValidatorPath @ValidationParameters
58+
}
59+
finally {
60+
Remove-Item $TempExtractPath -Recurse -Force -ErrorAction SilentlyContinue
61+
}

0 commit comments

Comments
 (0)