ci: build native Windows ARM64 packages and publish paired updates (#707)

This commit is contained in:
Kevin Yue authored and GitHub committed 2026-11-15 02:34:19 +08:00
1 parent 5031d4dcfb
commit dedd06366e
9 files changed
+281 -100

No files matched your search

+58 -12
View File
@@ -1,6 +1,25 @@
name: Build Windows package name: Build Windows package
on: on:
workflow_dispatch:
inputs:
gp_ref:
type: string
required: true
gpgui_ref:
type: string
required: true
channel:
type: choice
options: [snapshot, stable]
default: snapshot
build:
type: string
required: true
architecture:
type: choice
options: [x64, arm64]
required: true
workflow_call: workflow_call:
inputs: inputs:
gp_ref: gp_ref:
@@ -15,6 +34,9 @@ on:
build: build:
type: string type: string
required: true required: true
architecture:
type: string
required: true
secrets: secrets:
GH_PAT: GH_PAT:
required: true required: true
@@ -26,9 +48,10 @@ permissions:
jobs: jobs:
build: build:
runs-on: windows-2022 runs-on: ${{ inputs.architecture == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
timeout-minutes: 120 timeout-minutes: 120
env: env:
BUILD_ARCHITECTURE: ${{ inputs.architecture }}
CARGO_INCREMENTAL: '0' CARGO_INCREMENTAL: '0'
CARGO_TARGET_DIR: ${{ github.workspace }}/target-windows CARGO_TARGET_DIR: ${{ github.workspace }}/target-windows
CARGO_BUILD_JOBS: '2' CARGO_BUILD_JOBS: '2'
@@ -37,6 +60,19 @@ jobs:
GPGUI_WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }} GPGUI_WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }}
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }} GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
steps: steps:
- name: Select native build tools
id: native
shell: pwsh
run: |
if ($env:BUILD_ARCHITECTURE -eq 'arm64') {
'msystem=CLANGARM64' >> $env:GITHUB_OUTPUT
'subsystem=clangarm64' >> $env:GITHUB_OUTPUT
'packages=mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-pkgconf mingw-w64-clang-aarch64-gnutls mingw-w64-clang-aarch64-libxml2 mingw-w64-clang-aarch64-lz4' >> $env:GITHUB_OUTPUT
} elseif ($env:BUILD_ARCHITECTURE -eq 'x64') {
'msystem=UCRT64' >> $env:GITHUB_OUTPUT
'subsystem=ucrt64' >> $env:GITHUB_OUTPUT
'packages=mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-pkgconf mingw-w64-ucrt-x86_64-gnutls mingw-w64-ucrt-x86_64-libxml2 mingw-w64-ucrt-x86_64-lz4' >> $env:GITHUB_OUTPUT
} else { throw 'Unsupported Windows architecture.' }
- uses: actions/checkout@v6 - uses: actions/checkout@v6
with: with:
path: .ci path: .ci
@@ -59,13 +95,11 @@ jobs:
- uses: msys2/setup-msys2@v2 - uses: msys2/setup-msys2@v2
id: msys2 id: msys2
with: with:
msystem: UCRT64 msystem: ${{ steps.native.outputs.msystem }}
update: true update: true
install: >- install: >-
base-devel autoconf automake libtool gettext git base-devel autoconf automake libtool gettext git
mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-pkgconf ${{ steps.native.outputs.packages }}
mingw-w64-ucrt-x86_64-gnutls mingw-w64-ucrt-x86_64-libxml2
mingw-w64-ucrt-x86_64-lz4
- name: Prepare pinned installer and driver inputs - name: Prepare pinned installer and driver inputs
shell: pwsh shell: pwsh
run: | run: |
@@ -88,8 +122,8 @@ jobs:
run: | run: |
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$prefix = Join-Path $env:RUNNER_TEMP 'native-windows' $prefix = Join-Path $env:RUNNER_TEMP 'native-windows'
& ./source/gp/scripts/build-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ucrt64 -Prefix $prefix & ./source/gp/scripts/build-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ${{ steps.native.outputs.subsystem }} -Prefix $prefix
& ./source/gp/scripts/test-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ucrt64 -Prefix $prefix & ./source/gp/scripts/test-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ${{ steps.native.outputs.subsystem }} -Prefix $prefix
"OPENCONNECT_WINDOWS_PREFIX=$prefix" >> $env:GITHUB_ENV "OPENCONNECT_WINDOWS_PREFIX=$prefix" >> $env:GITHUB_ENV
- name: Build and package the matching Windows runtime - name: Build and package the matching Windows runtime
shell: pwsh shell: pwsh
@@ -101,13 +135,17 @@ jobs:
# Compiler diagnostics may contain private GUI source. Keep them on the runner. # Compiler diagnostics may contain private GUI source. Keep them on the runner.
try { try {
& ./source/gpgui/scripts/build-windows.ps1 -Profile Release ` & ./source/gpgui/scripts/build-windows.ps1 -Profile Release `
-NativePrefix $env:OPENCONNECT_WINDOWS_PREFIX -MsysRoot $env:MSYS_ROOT -MsysSubsystem ucrt64 ` -NativePrefix $env:OPENCONNECT_WINDOWS_PREFIX -MsysRoot $env:MSYS_ROOT -MsysSubsystem ${{ steps.native.outputs.subsystem }} `
-WintunDirectory (Join-Path $env:WINDOWS_BUILD_TOOLS 'wintun') ` -WintunDirectory (Join-Path $env:WINDOWS_BUILD_TOOLS 'wintun') `
-MakeNsis (Join-Path ${env:ProgramFiles(x86)} 'NSIS/makensis.exe') ` -MakeNsis (Join-Path ${env:ProgramFiles(x86)} 'NSIS/makensis.exe') `
-OutputDirectory "$env:GITHUB_WORKSPACE/artifacts" *> $log -OutputDirectory "$env:GITHUB_WORKSPACE/artifacts" *> $log
} catch { throw 'Windows compilation or packaging failed; private diagnostics remain on the runner.' } } catch {
python ./.ci/scripts/private-ci-diagnostics.py compile $log
throw 'Windows compilation or packaging failed; private diagnostics remain on the runner.'
}
Write-Host 'Windows compilation and packaging passed.' Write-Host 'Windows compilation and packaging passed.'
- name: Sign and verify update payload - name: Sign and verify update payload
id: sign
shell: pwsh shell: pwsh
env: env:
UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }} UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }}
@@ -117,7 +155,7 @@ jobs:
try { try {
[IO.File]::WriteAllText($key, $env:UPDATE_PRIVATE_KEY.Trim()) [IO.File]::WriteAllText($key, $env:UPDATE_PRIVATE_KEY.Trim())
. ./source/gpgui/scripts/windows-updates/Get-WinSparkle.ps1 . ./source/gpgui/scripts/windows-updates/Get-WinSparkle.ps1
$tools = Get-WinSparkleTools "$env:GITHUB_WORKSPACE/artifacts/tools" $tools = Get-WinSparkleTools "$env:GITHUB_WORKSPACE/artifacts/tools" -Architecture $env:BUILD_ARCHITECTURE
$installer = @(Get-ChildItem artifacts -Filter '*-setup.exe') $installer = @(Get-ChildItem artifacts -Filter '*-setup.exe')
if ($installer.Count -ne 1) { throw 'Expected exactly one Windows installer.' } if ($installer.Count -ne 1) { throw 'Expected exactly one Windows installer.' }
$signature = (& $tools.Tool sign -f $key $installer[0].FullName | Out-String).Trim() $signature = (& $tools.Tool sign -f $key $installer[0].FullName | Out-String).Trim()
@@ -129,13 +167,21 @@ jobs:
Remove-Item $key -Force -ErrorAction SilentlyContinue Remove-Item $key -Force -ErrorAction SilentlyContinue
Remove-Item artifacts/tools -Recurse -Force -ErrorAction SilentlyContinue Remove-Item artifacts/tools -Recurse -Force -ErrorAction SilentlyContinue
} }
- name: Test native installer and uninstaller
shell: pwsh
run: |
$installer = @(Get-ChildItem artifacts -Filter '*-setup.exe')
if ($installer.Count -ne 1) { throw 'Expected exactly one Windows installer.' }
& ./source/gp/scripts/test-windows-installer.ps1 -Installer $installer[0].FullName -Architecture $env:BUILD_ARCHITECTURE -Build $env:GPGUI_BUILD_VERSION
- uses: actions/upload-artifact@v7 - uses: actions/upload-artifact@v7
if: ${{ !cancelled() && steps.sign.outcome == 'success' }}
with: with:
name: artifact-gpgui-windows-x64 name: artifact-gpgui-windows-${{ inputs.architecture }}
path: | path: |
artifacts/*.exe artifacts/*.exe
artifacts/*.sig artifacts/*.sig
artifacts/*.sha256 artifacts/*.sha256
artifacts/*.zip artifacts/*.zip
overwrite: true
if-no-files-found: error if-no-files-found: error
retention-days: 14 retention-days: 7
+6 -1
View File
@@ -43,7 +43,7 @@ on:
default: false default: false
type: boolean type: boolean
build_windows: build_windows:
description: 'Build the Windows x64 NSH installer and development ZIP' description: 'Build Windows x64 and ARM64 NSH installers and development ZIPs'
required: true required: true
default: false default: false
type: boolean type: boolean
@@ -473,8 +473,13 @@ jobs:
build-windows: build-windows:
needs: validate-inputs needs: validate-inputs
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_windows) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_WINDOWS_ON_TAG == 'true') }} if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_windows) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_WINDOWS_ON_TAG == 'true') }}
strategy:
fail-fast: false
matrix:
architecture: [x64, arm64]
uses: ./.github/workflows/build-windows.yaml uses: ./.github/workflows/build-windows.yaml
with: with:
architecture: ${{ matrix.architecture }}
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }} gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }} gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }} channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
@@ -9,11 +9,7 @@ on:
default: main default: main
type: string type: string
release_tag: release_tag:
description: GitHub release containing the tested installer and detached signature description: GitHub release containing both tested native installers and signatures
required: true
type: string
installer_name:
description: Exact Windows x64 installer asset name
required: true required: true
type: string type: string
version: version:
@@ -46,7 +42,6 @@ jobs:
env: env:
REPOSITORY: yuezk/GlobalProtect-openconnect REPOSITORY: yuezk/GlobalProtect-openconnect
RELEASE_TAG: ${{ inputs.release_tag }} RELEASE_TAG: ${{ inputs.release_tag }}
INSTALLER_NAME: ${{ inputs.installer_name }}
PRODUCT_VERSION: ${{ inputs.version }} PRODUCT_VERSION: ${{ inputs.version }}
UPDATE_CHANNEL: ${{ inputs.channel }} UPDATE_CHANNEL: ${{ inputs.channel }}
BUILD_VERSION: ${{ inputs.build }} BUILD_VERSION: ${{ inputs.build }}
@@ -72,7 +67,7 @@ jobs:
- uses: actions/setup-node@v6 - uses: actions/setup-node@v6
with: with:
node-version: 22 node-version: 22
- name: Verify tested release installer - name: Verify both tested native installers
shell: pwsh shell: pwsh
run: | run: |
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
@@ -82,28 +77,31 @@ jobs:
} elseif ($env:RELEASE_TAG -ne 'snapshot' -or $env:BUILD_VERSION -notmatch '^\d+(\.\d+){0,2}$') { throw 'Snapshot release identity does not match.' } } elseif ($env:RELEASE_TAG -ne 'snapshot' -or $env:BUILD_VERSION -notmatch '^\d+(\.\d+){0,2}$') { throw 'Snapshot release identity does not match.' }
$displayVersion = $env:PRODUCT_VERSION $displayVersion = $env:PRODUCT_VERSION
if ($env:UPDATE_CHANNEL -eq 'snapshot') { $displayVersion += "-snapshot.$env:BUILD_VERSION" } if ($env:UPDATE_CHANNEL -eq 'snapshot') { $displayVersion += "-snapshot.$env:BUILD_VERSION" }
if ($env:INSTALLER_NAME -ne "GPConnect_${displayVersion}_windows-x64-setup.exe") { throw 'Installer asset does not match the product version, channel and build.' }
if (!$env:WINDOWS_UPDATE_PUBLIC_KEY) { throw 'Configure the Windows public update key before promotion.' } if (!$env:WINDOWS_UPDATE_PUBLIC_KEY) { throw 'Configure the Windows public update key before promotion.' }
$downloads = Join-Path $env:RUNNER_TEMP 'windows-update' $downloads = Join-Path $env:RUNNER_TEMP 'windows-update'
New-Item -ItemType Directory -Force $downloads | Out-Null New-Item -ItemType Directory -Force $downloads | Out-Null
foreach ($asset in @($env:INSTALLER_NAME, "$env:INSTALLER_NAME.sig", "$env:INSTALLER_NAME.sha256")) {
gh release download $env:RELEASE_TAG --repo $env:REPOSITORY --pattern $asset --dir $downloads
if ($LASTEXITCODE -ne 0) { throw "Missing release asset: $asset" }
}
$installer = Join-Path $downloads $env:INSTALLER_NAME
$sum = (Get-Content "$installer.sha256" -Raw).Trim()
if ($sum -notmatch '^([a-fA-F0-9]{64}) (.+)$' -or $Matches[2] -ne $env:INSTALLER_NAME) { throw 'Invalid installer checksum file.' }
if ((Get-FileHash $installer).Hash -ne $Matches[1]) { throw 'Installer checksum mismatch.' }
if ($env:WINDOWS_SIGNING_PUBLISHER) {
$authenticode = Get-AuthenticodeSignature $installer
if ($authenticode.Status -ne 'Valid' -or $authenticode.SignerCertificate.GetNameInfo([Security.Cryptography.X509Certificates.X509NameType]::SimpleName, $false) -ne $env:WINDOWS_SIGNING_PUBLISHER) { throw 'Installer publisher signature is invalid.' }
}
if ([Diagnostics.FileVersionInfo]::GetVersionInfo($installer).ProductVersion -ne $displayVersion) { throw 'Installer product version/build mismatch.' }
. ./gpgui/scripts/windows-updates/Get-WinSparkle.ps1 . ./gpgui/scripts/windows-updates/Get-WinSparkle.ps1
$tools = Get-WinSparkleTools (Join-Path $env:RUNNER_TEMP 'signing-tools') $tools = Get-WinSparkleTools (Join-Path $env:RUNNER_TEMP 'signing-tools')
$signature = (Get-Content "$installer.sig" -Raw).Trim() foreach ($architecture in @('x64','arm64')) {
& $tools.Tool verify -p $env:WINDOWS_UPDATE_PUBLIC_KEY -s $signature $installer $name = "GPConnect_${displayVersion}_windows-$architecture-setup.exe"
if ($LASTEXITCODE -ne 0) { throw 'Installer update signature is invalid.' } foreach ($asset in @($name, "$name.sig", "$name.sha256")) {
gh release download $env:RELEASE_TAG --repo $env:REPOSITORY --pattern $asset --dir $downloads
if ($LASTEXITCODE -ne 0) { throw "Missing release asset: $asset" }
}
$installer = Join-Path $downloads $name
$sum = (Get-Content "$installer.sha256" -Raw).Trim()
if ($sum -notmatch '^([a-fA-F0-9]{64}) (.+)$' -or $Matches[2] -ne $name) { throw 'Invalid installer checksum file.' }
if ((Get-FileHash $installer).Hash -ne $Matches[1]) { throw 'Installer checksum mismatch.' }
if ($env:WINDOWS_SIGNING_PUBLISHER) {
$authenticode = Get-AuthenticodeSignature $installer
if ($authenticode.Status -ne 'Valid' -or $authenticode.SignerCertificate.GetNameInfo([Security.Cryptography.X509Certificates.X509NameType]::SimpleName, $false) -ne $env:WINDOWS_SIGNING_PUBLISHER) { throw 'Installer publisher signature is invalid.' }
}
if ([Diagnostics.FileVersionInfo]::GetVersionInfo($installer).ProductVersion -ne $displayVersion) { throw 'Installer product version/build mismatch.' }
$signature = (Get-Content "$installer.sig" -Raw).Trim()
& $tools.Tool verify -p $env:WINDOWS_UPDATE_PUBLIC_KEY -s $signature $installer
if ($LASTEXITCODE -ne 0) { throw 'Installer update signature is invalid.' }
}
"WINDOWS_DISPLAY_VERSION=$displayVersion" >> $env:GITHUB_ENV
- name: Preserve other feeds and generate Windows metadata - name: Preserve other feeds and generate Windows metadata
shell: pwsh shell: pwsh
run: | run: |
@@ -115,12 +113,15 @@ jobs:
$env:UPDATE_HIGHLIGHTS | Set-Content $notes -Encoding utf8NoBOM $env:UPDATE_HIGHLIGHTS | Set-Content $notes -Encoding utf8NoBOM
$output = Join-Path $public 'windows' $output = Join-Path $public 'windows'
$previous = Join-Path $output 'latest.json' $previous = Join-Path $output 'latest.json'
$installer = Join-Path (Join-Path $env:RUNNER_TEMP 'windows-update') $env:INSTALLER_NAME $arguments = @('scripts/windows-update-feed.py', '--version', $env:PRODUCT_VERSION,
$arguments = @('scripts/windows-update-feed.py', '--installer', $installer,
'--installer-url', "https://github.com/$env:REPOSITORY/releases/download/$env:RELEASE_TAG/$env:INSTALLER_NAME",
'--signature-file', "$installer.sig", '--version', $env:PRODUCT_VERSION,
'--channel', $env:UPDATE_CHANNEL, '--released-at', [DateTime]::UtcNow.ToString('yyyy-MM-dd'), '--channel', $env:UPDATE_CHANNEL, '--released-at', [DateTime]::UtcNow.ToString('yyyy-MM-dd'),
'--highlights-file', $notes, '--output', $output) '--highlights-file', $notes, '--output', $output)
foreach ($architecture in @('x64','arm64')) {
$name = "GPConnect_$($env:WINDOWS_DISPLAY_VERSION)_windows-$architecture-setup.exe"
$installer = Join-Path (Join-Path $env:RUNNER_TEMP 'windows-update') $name
$arguments += @('--payload', $architecture, $installer,
"https://github.com/$env:REPOSITORY/releases/download/$env:RELEASE_TAG/$name", "$installer.sig")
}
if (Test-Path $previous) { $arguments += @('--input', $previous) } if (Test-Path $previous) { $arguments += @('--input', $previous) }
if ($env:BUILD_VERSION) { $arguments += @('--build', $env:BUILD_VERSION) } if ($env:BUILD_VERSION) { $arguments += @('--build', $env:BUILD_VERSION) }
python @arguments python @arguments
+1 -1
View File
@@ -175,7 +175,7 @@ release_snapshot() {
# The appcast publisher removes expired macOS snapshots after the new feed # The appcast publisher removes expired macOS snapshots after the new feed
# is live. Removing them here would temporarily break the current feed. # is live. Removing them here would temporarily break the current feed.
if [[ "$asset" == GPConnect_*_arm64.* || "$asset" == GPConnect_*_windows-x64-setup.exe* ]]; then if [[ "$asset" == GPConnect_*_arm64.* || "$asset" == GPConnect_*_windows-x64-setup.exe* || "$asset" == GPConnect_*_windows-arm64-setup.exe* ]]; then
continue continue
fi fi
if ! delete_release_asset "$asset"; then if ! delete_release_asset "$asset"; then
+16
View File
@@ -8,6 +8,18 @@ import sys
def report_compile(output): def report_compile(output):
output = re.sub(r'\x1b\[[0-9;]*[A-Za-z]', '', output)
stages = re.findall(r'^GP_WINDOWS_BUILD_STAGE=(core|gui|bundle|installer)\r?$', output, re.MULTILINE)
if stages:
print(f'::error::Windows build stage: {stages[-1]}.')
locations = re.findall(r'(?:-->\s+|panicked at )([^\r\n]+?):([0-9]+):([0-9]+)', output)
for path, line, column in sorted(set(locations)):
path = path.replace('\\', '/')
for prefix in ('/source/gpgui/', '/source/gp/'):
if prefix in path:
path = path.split(prefix, 1)[1]
fingerprint = hashlib.sha256(path.encode()).hexdigest()
print(f'::error::Rust source location fingerprint: {fingerprint} {line}:{column}')
codes = sorted(set(re.findall(r'error\[E[0-9]{4}\]', output))) codes = sorted(set(re.findall(r'error\[E[0-9]{4}\]', output)))
if codes: if codes:
print(f'::error::Rust diagnostic codes: {" ".join(codes)}.') print(f'::error::Rust diagnostic codes: {" ".join(codes)}.')
@@ -17,6 +29,10 @@ def report_compile(output):
'compiler or linker killed by SIGKILL'), 'compiler or linker killed by SIGKILL'),
(r'undefined reference to|undefined symbol:', 'unresolved linker symbols'), (r'undefined reference to|undefined symbol:', 'unresolved linker symbols'),
('proc macro panicked', 'procedural macro failed'), ('proc macro panicked', 'procedural macro failed'),
(r'Review runtime license notices for|Required runtime notice is missing',
'runtime library notices require review'),
('Unresolved Windows runtime dependency:', 'Windows runtime dependency is missing'),
(r'out of memory|paging file is too small|os error 1455', 'memory exhausted'),
] ]
for pattern, description in categories: for pattern, description in categories:
if re.search(pattern, output): if re.search(pattern, output):
+46
View File
@@ -0,0 +1,46 @@
# Exercise a candidate installer only on an empty CI machine.
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][string]$Installer,
[Parameter(Mandatory=$true)][ValidateSet('x64','arm64')][string]$Architecture,
[Parameter(Mandatory=$true)][AllowEmptyString()][string]$Build
)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$destination = Join-Path $env:ProgramFiles 'GP Connect'
if ((Test-Path $destination) -or (Get-Service GPConnect -ErrorAction SilentlyContinue)) {
throw 'Run this installer test on a clean Windows test machine.'
}
$process = Start-Process $Installer -ArgumentList '/S' -PassThru -Wait
if ($process.ExitCode -ne 0) {
# This test requires an empty CI installation; this log contains only installer operations.
$log = Join-Path $env:ProgramData 'GP Connect\installer.log'
if (Test-Path $log) { Get-Content $log -Tail 80 | Write-Host }
throw "The installer failed with exit code $($process.ExitCode)."
}
$info = Get-Content (Join-Path $destination 'build-info.json') -Raw | ConvertFrom-Json
if ($info.architecture -ne $Architecture -or [string]$info.build_version -ne $Build) { throw 'The installed package identity does not match.' }
$service = Get-CimInstance Win32_Service -Filter "Name='GPConnect'"
if ($service.State -ne 'Running' -or $service.StartMode -ne 'Auto' -or $service.StartName -ne 'LocalSystem') {
throw 'The service did not start automatically as LocalSystem.'
}
foreach ($name in @('gpgui.exe', 'gpauth.exe')) {
$process = Start-Process (Join-Path $destination $name) -ArgumentList '--version' -PassThru -Wait
if ($process.ExitCode -ne 0) { throw "The installed $name cannot start." }
}
$state = Join-Path $env:LOCALAPPDATA 'GP Connect\config\protected-state'
New-Item -ItemType Directory -Force $state | Out-Null
$marker = Join-Path $state 'ci-install-retention'
[IO.File]::WriteAllText($marker, 'retain user settings')
$process = Start-Process (Join-Path $destination 'uninstall.exe') -ArgumentList '/S' -PassThru -Wait
if ($process.ExitCode -ne 0) { throw 'The uninstaller failed.' }
if ((Get-Service GPConnect -ErrorAction SilentlyContinue) -or (Test-Path $destination) -or (Test-Path ($destination + '.previous'))) {
throw 'The uninstaller left service registration or runtime files.'
}
$shortcut = Join-Path $env:ProgramData 'Microsoft\Windows\Start Menu\Programs\GP Connect.lnk'
if ((Test-Path $shortcut) -or (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\GPConnect')) {
throw 'The uninstaller left its shortcut or registration.'
}
if ([IO.File]::ReadAllText($marker) -ne 'retain user settings') { throw 'The uninstaller changed user state.' }
Remove-Item $marker
Write-Host "Installed $Architecture runtime and service, launched both applications, and uninstalled successfully."
+17
View File
@@ -274,6 +274,23 @@ class PrivateTestStageTests(unittest.TestCase):
self.assertIn(expected, result.stdout) self.assertIn(expected, result.stdout)
self.assertNotRegex(result.stdout, r'(?m)^Rust tests: started') self.assertNotRegex(result.stdout, r'(?m)^Rust tests: started')
def test_compile_diagnostics_hash_source_locations_and_allowlist_windows_stage(self):
with tempfile.TemporaryDirectory() as temporary:
log = Path(temporary) / 'private.log'
log.write_text('GP_WINDOWS_BUILD_STAGE=gui\n'
'error[E0433]: PRIVATE_ERROR_MESSAGE\n'
' --> D:/a/repo/source/gpgui/crates/private.rs:42:9\n'
'PRIVATE_SOURCE_AND_CREDENTIALS\n')
result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'),
'compile', str(log)], capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stderr)
digest = hashlib.sha256(b'crates/private.rs').hexdigest()
self.assertEqual(result.stdout,
'::error::Windows build stage: gui.\n'
f'::error::Rust source location fingerprint: {digest} 42:9\n'
'::error::Rust diagnostic codes: error[E0433].\n')
self.assertEqual(result.stderr, '')
def test_test_diagnostics_hash_names_without_exposing_private_details(self): def test_test_diagnostics_hash_names_without_exposing_private_details(self):
with tempfile.TemporaryDirectory() as temporary: with tempfile.TemporaryDirectory() as temporary:
log = Path(temporary) / 'private.log' log = Path(temporary) / 'private.log'
+47 -15
View File
@@ -22,17 +22,17 @@ preserver = load("preserve_update_feeds", "preserve-update-feeds.py")
class WindowsFeedTests(unittest.TestCase): class WindowsFeedTests(unittest.TestCase):
def args(self, root, channel="stable", version="3.4.0", build=None): def args(self, root, channel="stable", version="3.4.0", build=None, architecture="x64"):
name = feed.installer_name(version, channel, build) name = feed.installer_name(version, channel, build, architecture)
installer = root / name installer = root / name
installer.write_bytes(b"test installer") installer.write_bytes(f"test installer {architecture}".encode())
signature = root / "installer.sig" signature = root / f"installer-{architecture}.sig"
signature.write_text(base64.b64encode(bytes(64)).decode()) signature.write_text(base64.b64encode(bytes([1 if architecture == "arm64" else 0]) * 64).decode())
highlights = root / "highlights.txt" highlights = root / "highlights.txt"
highlights.write_text("Update & improve <Windows>.\n") highlights.write_text("Update & improve <Windows>.\n")
tag = f"v{version}" if channel == "stable" else "snapshot" tag = f"v{version}" if channel == "stable" else "snapshot"
return argparse.Namespace(installer=installer, signature_file=signature, return argparse.Namespace(payload=[feed.Payload(architecture, installer,
installer_url=f"https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{tag}/{name}", f"https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{tag}/{name}", signature)],
repository="yuezk/GlobalProtect-openconnect", channel=channel, repository="yuezk/GlobalProtect-openconnect", channel=channel,
version=version, build=build, released_at="2026-11-14", version=version, build=build, released_at="2026-11-14",
highlights_file=highlights, input=None, output=root / "windows", allow_localhost=False) highlights_file=highlights, input=None, output=root / "windows", allow_localhost=False)
@@ -47,17 +47,49 @@ class WindowsFeedTests(unittest.TestCase):
self.assertEqual(item.findtext("description"), "Update & improve <Windows>.") self.assertEqual(item.findtext("description"), "Update & improve <Windows>.")
enclosure = item.find("enclosure") enclosure = item.find("enclosure")
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), catalog["stable"]["version"]) self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), catalog["stable"]["version"])
self.assertEqual(int(enclosure.get("length")), args.installer.stat().st_size) self.assertEqual(int(enclosure.get("length")), args.payload[0].installer.stat().st_size)
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}os"), "windows-x64") self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}os"), "windows-x64")
def test_native_architectures_share_one_release_with_separate_signed_enclosures(self):
with tempfile.TemporaryDirectory() as directory:
args = self.args(Path(directory))
arm = self.args(Path(directory), architecture="arm64")
args.payload += arm.payload
feed.generate(args)
items = ET.parse(args.output / "stable/appcast.xml").findall("channel/item")
self.assertEqual(len(items), 2)
for item, payload in zip(items, args.payload):
enclosure = item.find("enclosure")
self.assertEqual(enclosure.get("url"), payload.installer_url)
self.assertEqual(int(enclosure.get("length")), payload.installer.stat().st_size)
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}edSignature"), payload.signature_file.read_text())
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}os"), f"windows-{payload.architecture}")
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.4.0")
minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.19041"
self.assertEqual(item.findtext(f"{{{feed.SPARKLE}}}minimumSystemVersion"), minimum)
self.assertEqual(json.loads((args.output / "latest.json").read_text())["stable"]["platforms"], ["windows"])
def test_mismatched_or_duplicate_architecture_does_not_write_a_feed(self):
with tempfile.TemporaryDirectory() as directory:
args = self.args(Path(directory))
args.payload[0].architecture = "arm64"
with self.assertRaisesRegex(ValueError, "filename"):
feed.generate(args)
self.assertFalse(args.output.exists())
args.payload[0].architecture = "x64"
args.payload *= 2
with self.assertRaisesRegex(ValueError, "one installer per"):
feed.generate(args)
self.assertFalse(args.output.exists())
def test_snapshot_promotion_retains_stable_and_rejects_downgrade(self): def test_snapshot_promotion_retains_stable_and_rejects_downgrade(self):
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
args = self.args(Path(directory)) args = self.args(Path(directory))
feed.generate(args) feed.generate(args)
args.input = args.output / "latest.json" args.input = args.output / "latest.json"
args.channel, args.build = "snapshot", "2026.1114.2" args.channel, args.build = "snapshot", "2026.1114.2"
args.installer = args.installer.rename(args.installer.parent / feed.installer_name(args.version, args.channel, args.build)) args.payload[0].installer = args.payload[0].installer.rename(args.payload[0].installer.parent / feed.installer_name(args.version, args.channel, args.build))
args.installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.installer.name}" args.payload[0].installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.payload[0].installer.name}"
feed.generate(args) feed.generate(args)
catalog = json.loads(args.input.read_text()) catalog = json.loads(args.input.read_text())
self.assertEqual(catalog["stable"]["version"], "3.4.0") self.assertEqual(catalog["stable"]["version"], "3.4.0")
@@ -65,8 +97,8 @@ class WindowsFeedTests(unittest.TestCase):
enclosure = ET.parse(args.output / "snapshot/appcast.xml").find("channel/item/enclosure") enclosure = ET.parse(args.output / "snapshot/appcast.xml").find("channel/item/enclosure")
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.4.0-snapshot.2026.1114.2") self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.4.0-snapshot.2026.1114.2")
args.build = "2026.1114.1" args.build = "2026.1114.1"
args.installer = args.installer.rename(args.installer.parent / feed.installer_name(args.version, args.channel, args.build)) args.payload[0].installer = args.payload[0].installer.rename(args.payload[0].installer.parent / feed.installer_name(args.version, args.channel, args.build))
args.installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.installer.name}" args.payload[0].installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.payload[0].installer.name}"
with self.assertRaisesRegex(ValueError, "older"): with self.assertRaisesRegex(ValueError, "older"):
feed.generate(args) feed.generate(args)
@@ -91,7 +123,7 @@ class WindowsFeedTests(unittest.TestCase):
for channel in ("stable", "snapshot"): for channel in ("stable", "snapshot"):
enclosure = ET.parse(stable.output / channel / "appcast.xml").find("channel/item/enclosure") enclosure = ET.parse(stable.output / channel / "appcast.xml").find("channel/item/enclosure")
self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.5.0") self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.5.0")
self.assertEqual(enclosure.get("url"), stable.installer_url) self.assertEqual(enclosure.get("url"), stable.payload[0].installer_url)
def test_stable_without_snapshot_initializes_both_native_feeds(self): def test_stable_without_snapshot_initializes_both_native_feeds(self):
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
@@ -130,7 +162,7 @@ class WindowsFeedTests(unittest.TestCase):
def test_private_loopback_download_requires_explicit_opt_in(self): def test_private_loopback_download_requires_explicit_opt_in(self):
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
args = self.args(Path(directory)) args = self.args(Path(directory))
args.installer_url = "http://127.0.0.1:18770/setup.exe" args.payload[0].installer_url = "http://127.0.0.1:18770/setup.exe"
with self.assertRaisesRegex(ValueError, "matching GitHub"): with self.assertRaisesRegex(ValueError, "matching GitHub"):
feed.generate(args) feed.generate(args)
args.allow_localhost = True args.allow_localhost = True
@@ -139,7 +171,7 @@ class WindowsFeedTests(unittest.TestCase):
def test_missing_or_malformed_signature_is_rejected(self): def test_missing_or_malformed_signature_is_rejected(self):
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory:
args = self.args(Path(directory)) args = self.args(Path(directory))
args.signature_file.write_text("not a signature") args.payload[0].signature_file.write_text("not a signature")
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
feed.generate(args) feed.generate(args)
+61 -43
View File
@@ -1,9 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Build the Windows catalog and WinSparkle appcast from one verified installer.""" """Build one Windows catalog and appcast from verified native installers."""
from __future__ import annotations
import argparse import argparse
import base64 import base64
from dataclasses import dataclass
import hashlib import hashlib
import importlib.util import importlib.util
import json import json
@@ -18,14 +17,47 @@ manifest = importlib.util.module_from_spec(spec)
spec.loader.exec_module(manifest) spec.loader.exec_module(manifest)
@dataclass
class Payload:
architecture: str
installer: Path
installer_url: str
signature_file: Path
def release_version(version: str, channel: str, build: str | None) -> str: def release_version(version: str, channel: str, build: str | None) -> str:
if channel == "snapshot": if channel == "snapshot":
return f"{version}-snapshot.{build}" return f"{version}-snapshot.{build}"
return version return version
def installer_name(version: str, channel: str, build: str | None) -> str: def installer_name(version: str, channel: str, build: str | None, architecture: str = "x64") -> str:
return f"GPConnect_{release_version(version, channel, build)}_windows-x64-setup.exe" return f"GPConnect_{release_version(version, channel, build)}_windows-{architecture}-setup.exe"
def validate_payload(payload: Payload, args: argparse.Namespace) -> tuple[str, int]:
if payload.architecture not in {"x64", "arm64"}:
raise ValueError("unsupported Windows architecture")
expected_name = installer_name(args.version, args.channel, args.build, payload.architecture)
if not args.allow_localhost and payload.installer.name != expected_name:
raise ValueError("installer filename does not match the version, channel, build and architecture")
parsed = urlparse(payload.installer_url)
tag = f"v{args.version}" if args.channel == "stable" else "snapshot"
expected = f"https://github.com/{args.repository}/releases/download/{tag}/"
local = args.allow_localhost and parsed.scheme == "http" and parsed.hostname in {"localhost", "127.0.0.1", "::1"}
if not local and not payload.installer_url.startswith(expected):
raise ValueError("installer URL must identify the matching GitHub release asset")
if parsed.query or parsed.fragment or not parsed.path.endswith(".exe"):
raise ValueError("installer URL must name an EXE without query or fragment")
if not local and parsed.path.rsplit("/", 1)[-1] != expected_name:
raise ValueError("installer download filename does not match the version, channel, build and architecture")
signature = payload.signature_file.read_text(encoding="ascii").strip()
if len(base64.b64decode(signature, validate=True)) != 64:
raise ValueError("EdDSA signature must contain 64 bytes")
length = payload.installer.stat().st_size
if length == 0:
raise ValueError("installer is empty")
return signature, length
def generate(args: argparse.Namespace) -> None: def generate(args: argparse.Namespace) -> None:
@@ -36,25 +68,9 @@ def generate(args: argparse.Namespace) -> None:
manifest.build_tuple(args.build) manifest.build_tuple(args.build)
elif args.build is not None: elif args.build is not None:
raise ValueError("stable releases must not specify --build") raise ValueError("stable releases must not specify --build")
expected_name = installer_name(args.version, args.channel, args.build) if not args.payload or len({payload.architecture for payload in args.payload}) != len(args.payload):
if not args.allow_localhost and args.installer.name != expected_name: raise ValueError("provide one installer per Windows architecture")
raise ValueError("installer filename does not match the version, channel and build") prepared = [(payload, *validate_payload(payload, args)) for payload in args.payload]
parsed = urlparse(args.installer_url)
tag = f"v{args.version}" if args.channel == "stable" else "snapshot"
expected = f"https://github.com/{args.repository}/releases/download/{tag}/"
local = args.allow_localhost and parsed.scheme == "http" and parsed.hostname in {"localhost", "127.0.0.1", "::1"}
if not local and not args.installer_url.startswith(expected):
raise ValueError("installer URL must identify the matching GitHub release asset")
if parsed.query or parsed.fragment or not parsed.path.endswith(".exe"):
raise ValueError("installer URL must name an EXE without query or fragment")
if not local and parsed.path.rsplit("/", 1)[-1] != expected_name:
raise ValueError("installer download filename does not match the version, channel and build")
signature = args.signature_file.read_text(encoding="ascii").strip()
if len(base64.b64decode(signature, validate=True)) != 64:
raise ValueError("EdDSA signature must contain 64 bytes")
length = args.installer.stat().st_size
if length == 0:
raise ValueError("installer is empty")
if args.channel == "snapshot" and args.input is not None: if args.channel == "snapshot" and args.input is not None:
previous = manifest.validate_manifest(json.loads(args.input.read_text(encoding="utf-8")), args.repository) previous = manifest.validate_manifest(json.loads(args.input.read_text(encoding="utf-8")), args.repository)
stable = previous["stable"] stable = previous["stable"]
@@ -76,40 +92,40 @@ def generate(args: argparse.Namespace) -> None:
rss = ET.Element("rss", {"version": "2.0"}) rss = ET.Element("rss", {"version": "2.0"})
channel = ET.SubElement(rss, "channel") channel = ET.SubElement(rss, "channel")
ET.SubElement(channel, "title").text = "GP Connect for Windows" ET.SubElement(channel, "title").text = "GP Connect for Windows"
item = ET.SubElement(channel, "item") for payload, signature, length in prepared:
ET.SubElement(item, "title").text = f"GP Connect {display_version}" item = ET.SubElement(channel, "item")
ET.SubElement(item, "description").text = "\n".join(release["highlights"]) ET.SubElement(item, "title").text = f"GP Connect {display_version}"
ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = "10.0.19041" ET.SubElement(item, "description").text = "\n".join(release["highlights"])
ET.SubElement(item, "enclosure", { minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.19041"
"url": args.installer_url, "length": str(length), "type": "application/octet-stream", ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = minimum
f"{{{SPARKLE}}}version": display_version, ET.SubElement(item, "enclosure", {
f"{{{SPARKLE}}}shortVersionString": display_version, "url": payload.installer_url, "length": str(length), "type": "application/octet-stream",
f"{{{SPARKLE}}}os": "windows-x64", f"{{{SPARKLE}}}edSignature": signature, f"{{{SPARKLE}}}version": display_version,
}) f"{{{SPARKLE}}}shortVersionString": display_version,
f"{{{SPARKLE}}}os": f"windows-{payload.architecture}", f"{{{SPARKLE}}}edSignature": signature,
})
ET.indent(rss) ET.indent(rss)
channels = [args.channel] channels = [args.channel]
snapshot = data["snapshot"] snapshot = data["snapshot"]
if args.channel == "stable" and ( if args.channel == "stable" and (
snapshot is None or manifest.version_tuple(args.version) > manifest.version_tuple(snapshot["baseVersion"]) snapshot is None or manifest.version_tuple(args.version) > manifest.version_tuple(snapshot["baseVersion"])
): ):
# Core offers a newer stable release to snapshot installations too. # A newer stable release also updates snapshot installations.
# Keep the snapshot catalog history, but route its native install feed
# to the same newer stable candidate until a new snapshot is promoted.
channels.append("snapshot") channels.append("snapshot")
for target_channel in channels: for target_channel in channels:
channel_directory = output / target_channel channel_directory = output / target_channel
channel_directory.mkdir(exist_ok=True) channel_directory.mkdir(exist_ok=True)
ET.ElementTree(rss).write(channel_directory / "appcast.xml", encoding="utf-8", xml_declaration=True) ET.ElementTree(rss).write(channel_directory / "appcast.xml", encoding="utf-8", xml_declaration=True)
with args.installer.open("rb") as installer: for payload, _, _ in prepared:
digest = hashlib.file_digest(installer, "sha256").hexdigest() with payload.installer.open("rb") as installer:
(output / (args.installer.name + ".sha256")).write_text(f"{digest} {args.installer.name}\n", encoding="ascii") digest = hashlib.file_digest(installer, "sha256").hexdigest()
(output / (payload.installer.name + ".sha256")).write_text(f"{digest} {payload.installer.name}\n", encoding="ascii")
def main() -> None: def main() -> None:
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--installer", type=Path, required=True) parser.add_argument("--payload", nargs=4, action="append", required=True,
parser.add_argument("--installer-url", required=True) metavar=("ARCH", "INSTALLER", "URL", "SIGNATURE_FILE"))
parser.add_argument("--signature-file", type=Path, required=True)
parser.add_argument("--repository", default="yuezk/GlobalProtect-openconnect") parser.add_argument("--repository", default="yuezk/GlobalProtect-openconnect")
parser.add_argument("--channel", choices=("stable", "snapshot"), required=True) parser.add_argument("--channel", choices=("stable", "snapshot"), required=True)
parser.add_argument("--version", required=True) parser.add_argument("--version", required=True)
@@ -120,6 +136,8 @@ def main() -> None:
parser.add_argument("--output", type=Path, required=True) parser.add_argument("--output", type=Path, required=True)
parser.add_argument("--allow-localhost", action="store_true", help="Permit an isolated loopback test download") parser.add_argument("--allow-localhost", action="store_true", help="Permit an isolated loopback test download")
args = parser.parse_args() args = parser.parse_args()
args.payload = [Payload(architecture, Path(installer), url, Path(signature))
for architecture, installer, url, signature in args.payload]
try: try:
generate(args) generate(args)
except (OSError, ValueError) as error: except (OSError, ValueError) as error: