From fdbe3bcbba6f3cda58ae42ecbdabc4b8bebe4e49 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 14 Nov 2026 23:14:20 +0800 Subject: [PATCH 1/9] ci: add Windows package builds and verified update publication --- .github/workflows/build-windows.yaml | 144 +++++++++++++++ .github/workflows/build.yaml | 22 +++ .github/workflows/publish-update-feeds.yaml | 4 + .../publish-windows-update-feed.yaml | 151 ++++++++++++++++ scripts/gh-release.sh | 2 +- scripts/preserve-update-feeds.py | 44 +++++ scripts/tests/test_windows_update_feed.py | 164 ++++++++++++++++++ scripts/validate-update-manifest.py | 4 +- scripts/windows-update-feed.py | 130 ++++++++++++++ 9 files changed, 662 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-windows.yaml create mode 100644 .github/workflows/publish-windows-update-feed.yaml create mode 100644 scripts/preserve-update-feeds.py create mode 100644 scripts/tests/test_windows_update_feed.py create mode 100644 scripts/windows-update-feed.py diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml new file mode 100644 index 0000000..09d9bf8 --- /dev/null +++ b/.github/workflows/build-windows.yaml @@ -0,0 +1,144 @@ +name: Build Windows package + +on: + workflow_call: + inputs: + gp_ref: + type: string + required: true + gpgui_ref: + type: string + required: true + channel: + type: string + required: true + build: + type: string + required: true + secrets: + GH_PAT: + required: true + WINDOWS_UPDATE_PRIVATE_KEY: + required: true + +permissions: + contents: read + +jobs: + build: + runs-on: windows-2022 + timeout-minutes: 120 + env: + CARGO_INCREMENTAL: '0' + CARGO_TARGET_DIR: ${{ github.workspace }}/target-windows + CARGO_BUILD_JOBS: '2' + GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }} + GPGUI_BUILD_VERSION: ${{ inputs.channel == 'snapshot' && inputs.build || '' }} + GPGUI_WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }} + GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }} + steps: + - uses: actions/checkout@v6 + with: + path: .ci + persist-credentials: false + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.gp_ref }} + path: source/gp + submodules: recursive + persist-credentials: false + - uses: ./.ci/.github/actions/checkout-private + with: + token: ${{ secrets.GH_PAT }} + ref: ${{ inputs.gpgui_ref }} + path: source/gpgui + - uses: dtolnay/rust-toolchain@1.97.0 + - uses: actions/setup-python@v6 + with: + python-version: '3.13' + - uses: msys2/setup-msys2@v2 + id: msys2 + with: + msystem: MINGW64 + update: true + install: >- + base-devel autoconf automake libtool gettext git + mingw-w64-x86_64-gcc mingw-w64-x86_64-pkgconf + mingw-w64-x86_64-gnutls mingw-w64-x86_64-libxml2 + mingw-w64-x86_64-lz4 + - name: Prepare pinned installer and driver inputs + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + if (!$env:GPGUI_WINDOWS_UPDATE_PUBLIC_KEY -or !$env:GPGUI_LICENSE_SIGNING_KEYS) { throw 'Configure the Windows update and licensing public keys.' } + $tools = Join-Path $env:RUNNER_TEMP 'windows-tools' + New-Item -ItemType Directory -Force $tools | Out-Null + $nsis = Join-Path $tools 'nsis.zip' + Invoke-WebRequest 'https://downloads.sourceforge.net/project/nsis/NSIS%203/3.12/nsis-3.12.zip' -OutFile $nsis + if ((Get-FileHash $nsis).Hash -ne '56581F90DB321581C5381193D796FFFCF2D24B2F8FED2160A6C6A3BAA67F2C4F') { throw 'NSIS checksum mismatch.' } + Expand-Archive $nsis $tools + Remove-Item $nsis + $wintun = Join-Path $tools 'wintun.zip' + Invoke-WebRequest 'https://www.wintun.net/builds/wintun-0.14.1.zip' -OutFile $wintun + if ((Get-FileHash $wintun).Hash -ne '07C256185D6EE3652E09FA55C0B673E2624B565E02C4B9091C79CA7D2F24EF51') { throw 'Wintun checksum mismatch.' } + Expand-Archive $wintun $tools + Remove-Item $wintun + "WINDOWS_BUILD_TOOLS=$tools" >> $env:GITHUB_ENV + - name: Build OpenConnect and test native packet transport + shell: pwsh + env: + MSYS_ROOT: ${{ steps.msys2.outputs.msys2-location }} + run: | + $ErrorActionPreference = 'Stop' + $prefix = Join-Path $env:RUNNER_TEMP 'native-windows' + & ./source/gp/scripts/build-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -Prefix $prefix + & ./source/gp/scripts/test-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -Prefix $prefix + "OPENCONNECT_WINDOWS_PREFIX=$prefix" >> $env:GITHUB_ENV + - name: Build and package the matching Windows runtime + shell: pwsh + env: + MSYS_ROOT: ${{ steps.msys2.outputs.msys2-location }} + run: | + $ErrorActionPreference = 'Stop' + $log = Join-Path $env:RUNNER_TEMP 'windows-package.log' + # Compiler diagnostics may contain private GUI source. Keep them on the runner. + try { + & ./source/gpgui/scripts/build-windows.ps1 -Profile Release ` + -NativePrefix $env:OPENCONNECT_WINDOWS_PREFIX -MsysRoot $env:MSYS_ROOT ` + -WintunDirectory (Join-Path $env:WINDOWS_BUILD_TOOLS 'wintun') ` + -MakeNsis (Join-Path $env:WINDOWS_BUILD_TOOLS 'nsis-3.12/Bin/makensis.exe') ` + -OutputDirectory "$env:GITHUB_WORKSPACE/artifacts" *> $log + } catch { throw 'Windows compilation or packaging failed; private diagnostics remain on the runner.' } + Write-Host 'Windows compilation and packaging passed.' + - name: Sign and verify update payload + shell: pwsh + env: + UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }} + run: | + $ErrorActionPreference = 'Stop' + $key = Join-Path $env:RUNNER_TEMP 'windows-update.key' + try { + [IO.File]::WriteAllText($key, $env:UPDATE_PRIVATE_KEY.Trim()) + . ./source/gpgui/scripts/windows-updates/Get-WinSparkle.ps1 + $tools = Get-WinSparkleTools "$env:GITHUB_WORKSPACE/artifacts/tools" + $installer = @(Get-ChildItem artifacts -Filter '*-setup.exe') + if ($installer.Count -ne 1) { throw 'Expected exactly one Windows installer.' } + $signature = (& $tools.Tool sign -f $key $installer[0].FullName | Out-String).Trim() + if ($LASTEXITCODE -ne 0) { throw 'Windows update signing failed.' } + & $tools.Tool verify -p $env:GPGUI_WINDOWS_UPDATE_PUBLIC_KEY -s $signature $installer[0].FullName + if ($LASTEXITCODE -ne 0) { throw 'Windows update signature verification failed.' } + $signature | Set-Content ($installer[0].FullName + '.sig') -Encoding ascii + } finally { + Remove-Item $key -Force -ErrorAction SilentlyContinue + Remove-Item artifacts/tools -Recurse -Force -ErrorAction SilentlyContinue + } + - uses: actions/upload-artifact@v7 + with: + name: artifact-gpgui-windows-x64 + path: | + artifacts/*.exe + artifacts/*.sig + artifacts/*.sha256 + artifacts/*.zip + if-no-files-found: error + retention-days: 14 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3e97cbe..81a06e2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -42,6 +42,11 @@ on: required: true default: false type: boolean + build_windows: + description: 'Build the Windows x64 NSH installer and development ZIP' + required: true + default: false + type: boolean push: paths-ignore: - LICENSE @@ -465,6 +470,19 @@ jobs: secrets: GH_PAT: ${{ secrets.GH_PAT }} + build-windows: + needs: validate-inputs + if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_windows) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_WINDOWS_ON_TAG == 'true') }} + uses: ./.github/workflows/build-windows.yaml + with: + gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }} + gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }} + channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }} + build: ${{ format('{0}.{1}', github.run_number, github.run_attempt) }} + secrets: + GH_PAT: ${{ secrets.GH_PAT }} + WINDOWS_UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }} + nix-source: needs: [validate-inputs, build-gpgui-glibc] strategy: @@ -1191,6 +1209,7 @@ jobs: - build-gpgui-glibc - build-gpgui-musl - build-gpgui-nsh + - build-windows - setup-bsd-matrix - build-gpgui-frontend - build-bsd @@ -1201,6 +1220,7 @@ jobs: NEEDS_JSON: ${{ toJson(needs) }} BSD_MATRIX_ENABLED: ${{ needs.setup-bsd-matrix.outputs.enabled }} IS_STABLE: ${{ (startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }} + BUILD_WINDOWS: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_windows) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_WINDOWS_ON_TAG == 'true') }} run: | python3 - <<'PY' import json @@ -1220,6 +1240,8 @@ jobs: continue elif name in {"build-gpgui-frontend", "build-bsd"} and result == "skipped" and not bsd_matrix_enabled: continue + elif name == "build-windows" and result == "skipped" and os.environ["BUILD_WINDOWS"] != "true": + continue elif result == "skipped": failed.append(f"{name}: {result}") diff --git a/.github/workflows/publish-update-feeds.yaml b/.github/workflows/publish-update-feeds.yaml index c1157af..baac2de 100644 --- a/.github/workflows/publish-update-feeds.yaml +++ b/.github/workflows/publish-update-feeds.yaml @@ -533,6 +533,10 @@ jobs: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} run: | + python3 scripts/preserve-update-feeds.py \ + --base-url "${FEED_URL%/appcast.xml}" \ + --directory gpgui/apps/update-feed-worker/public \ + --exclude appcast.xml --exclude latest.json trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT ( set -euo pipefail diff --git a/.github/workflows/publish-windows-update-feed.yaml b/.github/workflows/publish-windows-update-feed.yaml new file mode 100644 index 0000000..d1bd9fb --- /dev/null +++ b/.github/workflows/publish-windows-update-feed.yaml @@ -0,0 +1,151 @@ +name: Publish Windows update feed + +on: + workflow_dispatch: + inputs: + gpgui_ref: + description: gpgui ref containing the update Worker and pinned WinSparkle tools + required: true + default: main + type: string + release_tag: + description: GitHub release containing the tested installer and detached signature + required: true + type: string + installer_name: + description: Exact Windows x64 installer asset name + required: true + type: string + version: + description: Base product version (x.y.z) + required: true + type: string + channel: + description: Update channel + required: true + type: choice + options: [stable, snapshot] + build: + description: Numeric snapshot build; empty for stable + type: string + highlights: + description: Release highlights, one per line + required: true + type: string + +concurrency: + group: update-feeds + cancel-in-progress: false + +jobs: + publish: + runs-on: windows-latest + environment: macos-release + permissions: + contents: read + env: + REPOSITORY: yuezk/GlobalProtect-openconnect + RELEASE_TAG: ${{ inputs.release_tag }} + INSTALLER_NAME: ${{ inputs.installer_name }} + PRODUCT_VERSION: ${{ inputs.version }} + UPDATE_CHANNEL: ${{ inputs.channel }} + BUILD_VERSION: ${{ inputs.build }} + UPDATE_HIGHLIGHTS: ${{ inputs.highlights }} + WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }} + WINDOWS_SIGNING_PUBLISHER: ${{ vars.WINDOWS_SIGNING_PUBLISHER }} + UPDATES_WORKER_NAME: ${{ vars.UPDATES_WORKER_NAME || 'gp-updates' }} + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v6 + - name: Checkout update Worker and build helpers + uses: ./.github/actions/checkout-private + with: + token: ${{ secrets.GH_PAT }} + ref: ${{ inputs.gpgui_ref }} + path: gpgui + - uses: actions/setup-python@v6 + with: + python-version: '3.13' + - uses: pnpm/action-setup@v5 + with: + version: 9.15.1 + - uses: actions/setup-node@v6 + with: + node-version: 22 + - name: Verify tested release installer + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + if ($env:PRODUCT_VERSION -notmatch '^\d+\.\d+\.\d+$') { throw 'Invalid product version.' } + if ($env:UPDATE_CHANNEL -eq 'stable') { + if ($env:RELEASE_TAG -ne "v$env:PRODUCT_VERSION" -or $env:BUILD_VERSION) { throw 'Stable 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 + 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.' } + $downloads = Join-Path $env:RUNNER_TEMP 'windows-update' + 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 + $tools = Get-WinSparkleTools (Join-Path $env:RUNNER_TEMP 'signing-tools') + $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.' } + - name: Preserve other feeds and generate Windows metadata + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $public = 'gpgui/apps/update-feed-worker/public' + python scripts/preserve-update-feeds.py --base-url https://updates.gpgui.com --directory $public + if ($LASTEXITCODE -ne 0) { throw 'Could not preserve published feeds.' } + $notes = Join-Path $env:RUNNER_TEMP 'windows-highlights.txt' + $env:UPDATE_HIGHLIGHTS | Set-Content $notes -Encoding utf8NoBOM + $output = Join-Path $public 'windows' + $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', '--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'), + '--highlights-file', $notes, '--output', $output) + if (Test-Path $previous) { $arguments += @('--input', $previous) } + if ($env:BUILD_VERSION) { $arguments += @('--build', $env:BUILD_VERSION) } + python @arguments + if ($LASTEXITCODE -ne 0) { throw 'Invalid Windows metadata.' } + - name: Deploy complete feed set + shell: pwsh + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + run: | + $ErrorActionPreference = 'Stop' + pnpm --dir gpgui/apps/update-feed-worker install --frozen-lockfile --ignore-scripts + if ($LASTEXITCODE -ne 0) { throw 'Worker dependency installation failed.' } + pnpm --dir gpgui/apps/update-feed-worker exec wrangler deploy --config wrangler.jsonc --name $env:UPDATES_WORKER_NAME + if ($LASTEXITCODE -ne 0) { throw 'Feed deployment failed.' } + - name: Verify published Windows metadata + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $windows = 'gpgui/apps/update-feed-worker/public/windows' + $feeds = @('latest.json', 'stable/appcast.xml', 'snapshot/appcast.xml') | Where-Object { Test-Path (Join-Path $windows $_) } + foreach ($relative in $feeds) { + $expected = [IO.File]::ReadAllBytes((Join-Path 'gpgui/apps/update-feed-worker/public/windows' $relative)) + $downloaded = Join-Path $env:RUNNER_TEMP ('published-' + ($relative -replace '/', '-')) + Invoke-WebRequest "https://updates.gpgui.com/windows/$relative" -OutFile $downloaded + $actual = [IO.File]::ReadAllBytes($downloaded) + if ([Convert]::ToBase64String($expected) -ne [Convert]::ToBase64String($actual)) { throw "Published feed does not match: $relative" } + } diff --git a/scripts/gh-release.sh b/scripts/gh-release.sh index 728ac6a..5245db4 100755 --- a/scripts/gh-release.sh +++ b/scripts/gh-release.sh @@ -175,7 +175,7 @@ release_snapshot() { # The appcast publisher removes expired macOS snapshots after the new feed # is live. Removing them here would temporarily break the current feed. - if [[ "$asset" == GPConnect_*_arm64.* ]]; then + if [[ "$asset" == GPConnect_*_arm64.* || "$asset" == GPConnect_*_windows-x64-setup.exe* ]]; then continue fi if ! delete_release_asset "$asset"; then diff --git a/scripts/preserve-update-feeds.py b/scripts/preserve-update-feeds.py new file mode 100644 index 0000000..ff6131a --- /dev/null +++ b/scripts/preserve-update-feeds.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Retain other platform/channel feeds before replacing a static Worker deployment.""" +import argparse +import json +from pathlib import Path +from urllib.error import HTTPError +from urllib.parse import urlparse +from urllib.request import urlopen +import xml.etree.ElementTree as ET + +FEEDS = ("appcast.xml", "latest.json", "windows/latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml") + + +def preserve(base_url: str, directory: Path, exclude: list[str]) -> None: + if urlparse(base_url).scheme != "https": + raise ValueError("feed host must use HTTPS") + for relative in FEEDS: + if relative in exclude: + continue + try: + with urlopen(base_url.rstrip("/") + "/" + relative, timeout=30) as response: + data = response.read(1024 * 1024 + 1) + except HTTPError as error: + if error.code == 404: + continue + raise + if len(data) > 1024 * 1024: + raise ValueError(f"published feed is too large: {relative}") + if relative.endswith(".json"): + json.loads(data) + else: + ET.fromstring(data) + target = directory / relative + target.parent.mkdir(parents=True, exist_ok=True) + target.write_bytes(data) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--base-url", required=True) + parser.add_argument("--directory", type=Path, required=True) + parser.add_argument("--exclude", action="append", default=[], choices=FEEDS) + args = parser.parse_args() + preserve(args.base_url, args.directory, args.exclude) diff --git a/scripts/tests/test_windows_update_feed.py b/scripts/tests/test_windows_update_feed.py new file mode 100644 index 0000000..525991c --- /dev/null +++ b/scripts/tests/test_windows_update_feed.py @@ -0,0 +1,164 @@ +import argparse +import base64 +import importlib.util +import json +from pathlib import Path +import tempfile +import unittest +from unittest.mock import patch +from urllib.error import HTTPError +import xml.etree.ElementTree as ET + + +def load(name, filename): + spec = importlib.util.spec_from_file_location(name, Path(__file__).parents[1] / filename) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +feed = load("windows_update_feed", "windows-update-feed.py") +preserver = load("preserve_update_feeds", "preserve-update-feeds.py") + + +class WindowsFeedTests(unittest.TestCase): + def args(self, root, channel="stable", version="3.4.0", build=None): + name = feed.installer_name(version, channel, build) + installer = root / name + installer.write_bytes(b"test installer") + signature = root / "installer.sig" + signature.write_text(base64.b64encode(bytes(64)).decode()) + highlights = root / "highlights.txt" + highlights.write_text("Update & improve .\n") + tag = f"v{version}" if channel == "stable" else "snapshot" + return argparse.Namespace(installer=installer, signature_file=signature, + installer_url=f"https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{tag}/{name}", + repository="yuezk/GlobalProtect-openconnect", channel=channel, + version=version, build=build, released_at="2026-11-14", + highlights_file=highlights, input=None, output=root / "windows", allow_localhost=False) + + def test_catalog_and_appcast_keep_the_same_version_and_payload(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory)) + feed.generate(args) + catalog = json.loads((args.output / "latest.json").read_text()) + self.assertEqual(catalog["stable"]["platforms"], ["windows"]) + item = ET.parse(args.output / "stable/appcast.xml").find("channel/item") + self.assertEqual(item.findtext("description"), "Update & improve .") + enclosure = item.find("enclosure") + self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), catalog["stable"]["version"]) + self.assertEqual(int(enclosure.get("length")), args.installer.stat().st_size) + self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}os"), "windows-x64") + + def test_snapshot_promotion_retains_stable_and_rejects_downgrade(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory)) + feed.generate(args) + args.input = args.output / "latest.json" + 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.installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.installer.name}" + feed.generate(args) + catalog = json.loads(args.input.read_text()) + self.assertEqual(catalog["stable"]["version"], "3.4.0") + self.assertEqual(catalog["snapshot"]["build"], "2026.1114.2") + 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") + args.build = "2026.1114.1" + args.installer = args.installer.rename(args.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}" + with self.assertRaisesRegex(ValueError, "older"): + feed.generate(args) + + def test_snapshot_filename_cannot_advertise_another_build(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory), "snapshot", build="2026.1114.1") + args.build = "2026.1114.2" + with self.assertRaisesRegex(ValueError, "filename does not match"): + feed.generate(args) + + def test_newer_stable_updates_both_native_feeds_and_retains_snapshot_history(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + snapshot = self.args(root, "snapshot", build="2026.1114.2") + feed.generate(snapshot) + stable = self.args(root, version="3.5.0") + stable.input = stable.output / "latest.json" + feed.generate(stable) + catalog = json.loads(stable.input.read_text()) + self.assertEqual(catalog["snapshot"]["baseVersion"], "3.4.0") + self.assertEqual(catalog["snapshot"]["build"], "2026.1114.2") + for channel in ("stable", "snapshot"): + 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("url"), stable.installer_url) + + def test_stable_without_snapshot_initializes_both_native_feeds(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory)) + feed.generate(args) + self.assertEqual((args.output / "stable/appcast.xml").read_bytes(), + (args.output / "snapshot/appcast.xml").read_bytes()) + self.assertIsNone(json.loads((args.output / "latest.json").read_text())["snapshot"]) + + def test_stable_does_not_replace_same_or_newer_base_snapshot_feed(self): + for snapshot_version in ("3.4.0", "3.5.0"): + with self.subTest(snapshot_version=snapshot_version), tempfile.TemporaryDirectory() as directory: + root = Path(directory) + snapshot = self.args(root, "snapshot", version=snapshot_version, build="2026.1114.2") + feed.generate(snapshot) + before = (snapshot.output / "snapshot/appcast.xml").read_bytes() + stable = self.args(root) + stable.input = stable.output / "latest.json" + feed.generate(stable) + self.assertEqual((stable.output / "snapshot/appcast.xml").read_bytes(), before) + + def test_snapshot_older_than_stable_is_rejected_without_changing_published_files(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + stable = self.args(root, version="3.5.0") + feed.generate(stable) + published = {relative: (stable.output / relative).read_bytes() + for relative in ("latest.json", "stable/appcast.xml", "snapshot/appcast.xml")} + snapshot = self.args(root, "snapshot", version="3.4.0", build="2026.1114.3") + snapshot.input = stable.output / "latest.json" + with self.assertRaisesRegex(ValueError, "snapshot base version is older"): + feed.generate(snapshot) + for relative, content in published.items(): + self.assertEqual((stable.output / relative).read_bytes(), content) + + def test_private_loopback_download_requires_explicit_opt_in(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory)) + args.installer_url = "http://127.0.0.1:18770/setup.exe" + with self.assertRaisesRegex(ValueError, "matching GitHub"): + feed.generate(args) + args.allow_localhost = True + feed.generate(args) + + def test_missing_or_malformed_signature_is_rejected(self): + with tempfile.TemporaryDirectory() as directory: + args = self.args(Path(directory)) + args.signature_file.write_text("not a signature") + with self.assertRaises(ValueError): + feed.generate(args) + + def test_preservation_keeps_other_feeds_and_does_not_hide_server_errors(self): + class Response: + def __enter__(self): return self + def __exit__(self, *unused): pass + def read(self, length): return b'{"schemaVersion": 1}' + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + with patch.object(preserver, "urlopen", return_value=Response()) as request: + preserver.preserve("https://updates.gpgui.com", root, + ["appcast.xml", "latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml"]) + self.assertTrue((root / "windows/latest.json").exists()) + self.assertEqual(request.call_count, 1) + with patch.object(preserver, "urlopen", side_effect=HTTPError("url", 500, "failure", {}, None)): + with self.assertRaises(HTTPError): + preserver.preserve("https://updates.gpgui.com", root, []) + + +if __name__ == "__main__": + unittest.main() diff --git a/scripts/validate-update-manifest.py b/scripts/validate-update-manifest.py index d47ec63..be3990a 100644 --- a/scripts/validate-update-manifest.py +++ b/scripts/validate-update-manifest.py @@ -10,7 +10,7 @@ import unicodedata from pathlib import Path from urllib.parse import urlparse -ALLOWED_PLATFORMS = {"linux", "freebsd", "openbsd"} +ALLOWED_PLATFORMS = {"linux", "freebsd", "openbsd", "windows"} SEMVER = re.compile(r"^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$") BUILD = re.compile(r"^(0|[1-9][0-9]*)(?:\.(0|[1-9][0-9]*)){0,2}$") EXPECTED_TOP_LEVEL_KEYS = {"schemaVersion", "stable", "snapshot"} @@ -192,7 +192,7 @@ def main() -> None: generate_parser.add_argument("--channel", choices=("stable", "snapshot"), required=True) generate_parser.add_argument("--version", required=True) generate_parser.add_argument("--platform", action="append", choices=sorted(ALLOWED_PLATFORMS), - help="Published Unix target; repeat for multiple targets (default: all)") + help="Published target; repeat for multiple targets (default: Unix targets)") generate_parser.add_argument("--build") generate_parser.add_argument("--released-at", required=True) generate_parser.add_argument("--highlights-file", required=True, type=Path) diff --git a/scripts/windows-update-feed.py b/scripts/windows-update-feed.py new file mode 100644 index 0000000..9e3a2ab --- /dev/null +++ b/scripts/windows-update-feed.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +"""Build the Windows catalog and WinSparkle appcast from one verified installer.""" +from __future__ import annotations + +import argparse +import base64 +import hashlib +import importlib.util +import json +from pathlib import Path +from urllib.parse import urlparse +import xml.etree.ElementTree as ET + +SPARKLE = "http://www.andymatuschak.org/xml-namespaces/sparkle" +ET.register_namespace("sparkle", SPARKLE) +spec = importlib.util.spec_from_file_location("update_manifest", Path(__file__).with_name("validate-update-manifest.py")) +manifest = importlib.util.module_from_spec(spec) +spec.loader.exec_module(manifest) + + +def release_version(version: str, channel: str, build: str | None) -> str: + if channel == "snapshot": + return f"{version}-snapshot.{build}" + return version + + +def installer_name(version: str, channel: str, build: str | None) -> str: + return f"GPConnect_{release_version(version, channel, build)}_windows-x64-setup.exe" + + +def generate(args: argparse.Namespace) -> None: + manifest.version_tuple(args.version) + if args.channel == "snapshot": + if args.build is None: + raise ValueError("snapshot releases require --build") + manifest.build_tuple(args.build) + elif args.build is not None: + raise ValueError("stable releases must not specify --build") + expected_name = installer_name(args.version, args.channel, args.build) + if not args.allow_localhost and args.installer.name != expected_name: + raise ValueError("installer filename does not match the version, channel and build") + 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: + previous = manifest.validate_manifest(json.loads(args.input.read_text(encoding="utf-8")), args.repository) + stable = previous["stable"] + if stable is not None and manifest.version_tuple(args.version) < manifest.version_tuple(stable["version"]): + raise ValueError("snapshot base version is older than the published stable release") + output = args.output + output.mkdir(parents=True, exist_ok=True) + catalog = output / "latest.json" + manifest.generate(argparse.Namespace( + repository=args.repository, channel=args.channel, version=args.version, + platform=["windows"], build=args.build, released_at=args.released_at, + highlights_file=args.highlights_file, input=args.input, output=catalog, + )) + data = json.loads(catalog.read_text(encoding="utf-8")) + if any(release and release["platforms"] != ["windows"] for release in [data["stable"], data["snapshot"]]): + raise ValueError("Windows catalog may contain only the Windows target") + release = data[args.channel] + display_version = release_version(args.version, args.channel, args.build) + rss = ET.Element("rss", {"version": "2.0"}) + channel = ET.SubElement(rss, "channel") + ET.SubElement(channel, "title").text = "GP Connect for Windows" + item = ET.SubElement(channel, "item") + ET.SubElement(item, "title").text = f"GP Connect {display_version}" + ET.SubElement(item, "description").text = "\n".join(release["highlights"]) + ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = "10.0.19041" + ET.SubElement(item, "enclosure", { + "url": args.installer_url, "length": str(length), "type": "application/octet-stream", + f"{{{SPARKLE}}}version": display_version, + f"{{{SPARKLE}}}shortVersionString": display_version, + f"{{{SPARKLE}}}os": "windows-x64", f"{{{SPARKLE}}}edSignature": signature, + }) + ET.indent(rss) + channels = [args.channel] + snapshot = data["snapshot"] + if args.channel == "stable" and ( + snapshot is None or manifest.version_tuple(args.version) > manifest.version_tuple(snapshot["baseVersion"]) + ): + # Core offers a newer stable release to snapshot installations too. + # 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") + for target_channel in channels: + channel_directory = output / target_channel + channel_directory.mkdir(exist_ok=True) + ET.ElementTree(rss).write(channel_directory / "appcast.xml", encoding="utf-8", xml_declaration=True) + with args.installer.open("rb") as installer: + digest = hashlib.file_digest(installer, "sha256").hexdigest() + (output / (args.installer.name + ".sha256")).write_text(f"{digest} {args.installer.name}\n", encoding="ascii") + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--installer", type=Path, required=True) + parser.add_argument("--installer-url", required=True) + parser.add_argument("--signature-file", type=Path, required=True) + parser.add_argument("--repository", default="yuezk/GlobalProtect-openconnect") + parser.add_argument("--channel", choices=("stable", "snapshot"), required=True) + parser.add_argument("--version", required=True) + parser.add_argument("--build") + parser.add_argument("--released-at", required=True) + parser.add_argument("--highlights-file", type=Path, required=True) + parser.add_argument("--input", type=Path) + parser.add_argument("--output", type=Path, required=True) + parser.add_argument("--allow-localhost", action="store_true", help="Permit an isolated loopback test download") + args = parser.parse_args() + try: + generate(args) + except (OSError, ValueError) as error: + parser.error(str(error)) + + +if __name__ == "__main__": + main() From 9432f0c3e525a778d73bcdd59a2f039b8f83bba2 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 14 Nov 2026 23:38:27 +0800 Subject: [PATCH 2/9] fix: use pinned installer package and isolate feed preservation --- .github/workflows/build-windows.yaml | 23 +++++++++------------ .github/workflows/publish-update-feeds.yaml | 11 ++++++---- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml index 09d9bf8..edb30ae 100644 --- a/.github/workflows/build-windows.yaml +++ b/.github/workflows/build-windows.yaml @@ -59,13 +59,13 @@ jobs: - uses: msys2/setup-msys2@v2 id: msys2 with: - msystem: MINGW64 + msystem: UCRT64 update: true install: >- base-devel autoconf automake libtool gettext git - mingw-w64-x86_64-gcc mingw-w64-x86_64-pkgconf - mingw-w64-x86_64-gnutls mingw-w64-x86_64-libxml2 - mingw-w64-x86_64-lz4 + 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 - name: Prepare pinned installer and driver inputs shell: pwsh run: | @@ -73,11 +73,8 @@ jobs: if (!$env:GPGUI_WINDOWS_UPDATE_PUBLIC_KEY -or !$env:GPGUI_LICENSE_SIGNING_KEYS) { throw 'Configure the Windows update and licensing public keys.' } $tools = Join-Path $env:RUNNER_TEMP 'windows-tools' New-Item -ItemType Directory -Force $tools | Out-Null - $nsis = Join-Path $tools 'nsis.zip' - Invoke-WebRequest 'https://downloads.sourceforge.net/project/nsis/NSIS%203/3.12/nsis-3.12.zip' -OutFile $nsis - if ((Get-FileHash $nsis).Hash -ne '56581F90DB321581C5381193D796FFFCF2D24B2F8FED2160A6C6A3BAA67F2C4F') { throw 'NSIS checksum mismatch.' } - Expand-Archive $nsis $tools - Remove-Item $nsis + choco install nsis --version=3.12.0 --yes --no-progress + if ($LASTEXITCODE -ne 0) { throw 'Installing NSIS 3.12 failed.' } $wintun = Join-Path $tools 'wintun.zip' Invoke-WebRequest 'https://www.wintun.net/builds/wintun-0.14.1.zip' -OutFile $wintun if ((Get-FileHash $wintun).Hash -ne '07C256185D6EE3652E09FA55C0B673E2624B565E02C4B9091C79CA7D2F24EF51') { throw 'Wintun checksum mismatch.' } @@ -91,8 +88,8 @@ jobs: run: | $ErrorActionPreference = 'Stop' $prefix = Join-Path $env:RUNNER_TEMP 'native-windows' - & ./source/gp/scripts/build-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -Prefix $prefix - & ./source/gp/scripts/test-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -Prefix $prefix + & ./source/gp/scripts/build-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ucrt64 -Prefix $prefix + & ./source/gp/scripts/test-openconnect-windows.ps1 -MsysRoot $env:MSYS_ROOT -MsysSubsystem ucrt64 -Prefix $prefix "OPENCONNECT_WINDOWS_PREFIX=$prefix" >> $env:GITHUB_ENV - name: Build and package the matching Windows runtime shell: pwsh @@ -104,9 +101,9 @@ jobs: # Compiler diagnostics may contain private GUI source. Keep them on the runner. try { & ./source/gpgui/scripts/build-windows.ps1 -Profile Release ` - -NativePrefix $env:OPENCONNECT_WINDOWS_PREFIX -MsysRoot $env:MSYS_ROOT ` + -NativePrefix $env:OPENCONNECT_WINDOWS_PREFIX -MsysRoot $env:MSYS_ROOT -MsysSubsystem ucrt64 ` -WintunDirectory (Join-Path $env:WINDOWS_BUILD_TOOLS 'wintun') ` - -MakeNsis (Join-Path $env:WINDOWS_BUILD_TOOLS 'nsis-3.12/Bin/makensis.exe') ` + -MakeNsis (Join-Path ${env:ProgramFiles(x86)} 'NSIS/makensis.exe') ` -OutputDirectory "$env:GITHUB_WORKSPACE/artifacts" *> $log } catch { throw 'Windows compilation or packaging failed; private diagnostics remain on the runner.' } Write-Host 'Windows compilation and packaging passed.' diff --git a/.github/workflows/publish-update-feeds.yaml b/.github/workflows/publish-update-feeds.yaml index baac2de..bdda15d 100644 --- a/.github/workflows/publish-update-feeds.yaml +++ b/.github/workflows/publish-update-feeds.yaml @@ -528,15 +528,18 @@ jobs: --channel "$CHANNEL" \ --archive-url "https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/$ARCHIVE_NAME" - - name: Deploy update feed worker - env: - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + - name: Preserve other platform feeds run: | python3 scripts/preserve-update-feeds.py \ --base-url "${FEED_URL%/appcast.xml}" \ --directory gpgui/apps/update-feed-worker/public \ --exclude appcast.xml --exclude latest.json + + - name: Deploy update feed worker + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + run: | trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Private operation failed; diagnostics suppressed."; fi' EXIT ( set -euo pipefail From 594ab0ea32b4e253faf3b2ff39cf4cfcd45823f8 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 14 Nov 2026 23:43:04 +0800 Subject: [PATCH 3/9] ci: preserve LF endings for native Windows build inputs --- .github/workflows/build-windows.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml index edb30ae..fa985ed 100644 --- a/.github/workflows/build-windows.yaml +++ b/.github/workflows/build-windows.yaml @@ -37,6 +37,9 @@ jobs: GPGUI_WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }} GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }} steps: + - name: Preserve Unix source line endings + shell: pwsh + run: git config --global core.autocrlf false - uses: actions/checkout@v6 with: path: .ci From 1ac01081e071f8deb72b8c49f71bbcb177268f3d Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sat, 14 Nov 2026 23:44:47 +0800 Subject: [PATCH 4/9] build: express source line endings through Git attributes --- .gitattributes | 2 ++ .github/workflows/build-windows.yaml | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..86b39e9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Keep source and build scripts consistent on every platform. +* text=auto eol=lf diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml index fa985ed..edb30ae 100644 --- a/.github/workflows/build-windows.yaml +++ b/.github/workflows/build-windows.yaml @@ -37,9 +37,6 @@ jobs: GPGUI_WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }} GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }} steps: - - name: Preserve Unix source line endings - shell: pwsh - run: git config --global core.autocrlf false - uses: actions/checkout@v6 with: path: .ci From dedd06366e6b5f0fb5533a82d6de132a39d38577 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 15 Nov 2026 02:34:19 +0800 Subject: [PATCH 5/9] ci: build native Windows ARM64 packages and publish paired updates (#707) --- .github/workflows/build-windows.yaml | 70 ++++++++++-- .github/workflows/build.yaml | 7 +- .../publish-windows-update-feed.yaml | 57 +++++----- scripts/gh-release.sh | 2 +- scripts/private-ci-diagnostics.py | 16 +++ scripts/test-windows-installer.ps1 | 46 ++++++++ scripts/tests/test_private_ci.py | 17 +++ scripts/tests/test_windows_update_feed.py | 62 ++++++++--- scripts/windows-update-feed.py | 104 ++++++++++-------- 9 files changed, 281 insertions(+), 100 deletions(-) create mode 100644 scripts/test-windows-installer.ps1 diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml index edb30ae..b80d3d2 100644 --- a/.github/workflows/build-windows.yaml +++ b/.github/workflows/build-windows.yaml @@ -1,6 +1,25 @@ name: Build Windows package 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: inputs: gp_ref: @@ -15,6 +34,9 @@ on: build: type: string required: true + architecture: + type: string + required: true secrets: GH_PAT: required: true @@ -26,9 +48,10 @@ permissions: jobs: build: - runs-on: windows-2022 + runs-on: ${{ inputs.architecture == 'arm64' && 'windows-11-arm' || 'windows-2022' }} timeout-minutes: 120 env: + BUILD_ARCHITECTURE: ${{ inputs.architecture }} CARGO_INCREMENTAL: '0' CARGO_TARGET_DIR: ${{ github.workspace }}/target-windows CARGO_BUILD_JOBS: '2' @@ -37,6 +60,19 @@ jobs: GPGUI_WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }} GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }} 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 with: path: .ci @@ -59,13 +95,11 @@ jobs: - uses: msys2/setup-msys2@v2 id: msys2 with: - msystem: UCRT64 + msystem: ${{ steps.native.outputs.msystem }} update: true install: >- base-devel autoconf automake libtool gettext git - 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 + ${{ steps.native.outputs.packages }} - name: Prepare pinned installer and driver inputs shell: pwsh run: | @@ -88,8 +122,8 @@ jobs: run: | $ErrorActionPreference = 'Stop' $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/test-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 ${{ steps.native.outputs.subsystem }} -Prefix $prefix "OPENCONNECT_WINDOWS_PREFIX=$prefix" >> $env:GITHUB_ENV - name: Build and package the matching Windows runtime shell: pwsh @@ -101,13 +135,17 @@ jobs: # Compiler diagnostics may contain private GUI source. Keep them on the runner. try { & ./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') ` -MakeNsis (Join-Path ${env:ProgramFiles(x86)} 'NSIS/makensis.exe') ` -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.' - name: Sign and verify update payload + id: sign shell: pwsh env: UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }} @@ -117,7 +155,7 @@ jobs: try { [IO.File]::WriteAllText($key, $env:UPDATE_PRIVATE_KEY.Trim()) . ./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') if ($installer.Count -ne 1) { throw 'Expected exactly one Windows installer.' } $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 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 + if: ${{ !cancelled() && steps.sign.outcome == 'success' }} with: - name: artifact-gpgui-windows-x64 + name: artifact-gpgui-windows-${{ inputs.architecture }} path: | artifacts/*.exe artifacts/*.sig artifacts/*.sha256 artifacts/*.zip + overwrite: true if-no-files-found: error - retention-days: 14 + retention-days: 7 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 81a06e2..d477aaf 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -43,7 +43,7 @@ on: default: false type: boolean 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 default: false type: boolean @@ -473,8 +473,13 @@ jobs: build-windows: needs: validate-inputs 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 with: + architecture: ${{ matrix.architecture }} gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }} gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }} channel: ${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }} diff --git a/.github/workflows/publish-windows-update-feed.yaml b/.github/workflows/publish-windows-update-feed.yaml index d1bd9fb..8a981c0 100644 --- a/.github/workflows/publish-windows-update-feed.yaml +++ b/.github/workflows/publish-windows-update-feed.yaml @@ -9,11 +9,7 @@ on: default: main type: string release_tag: - description: GitHub release containing the tested installer and detached signature - required: true - type: string - installer_name: - description: Exact Windows x64 installer asset name + description: GitHub release containing both tested native installers and signatures required: true type: string version: @@ -46,7 +42,6 @@ jobs: env: REPOSITORY: yuezk/GlobalProtect-openconnect RELEASE_TAG: ${{ inputs.release_tag }} - INSTALLER_NAME: ${{ inputs.installer_name }} PRODUCT_VERSION: ${{ inputs.version }} UPDATE_CHANNEL: ${{ inputs.channel }} BUILD_VERSION: ${{ inputs.build }} @@ -72,7 +67,7 @@ jobs: - uses: actions/setup-node@v6 with: node-version: 22 - - name: Verify tested release installer + - name: Verify both tested native installers shell: pwsh run: | $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.' } $displayVersion = $env:PRODUCT_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.' } $downloads = Join-Path $env:RUNNER_TEMP 'windows-update' 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 $tools = Get-WinSparkleTools (Join-Path $env:RUNNER_TEMP 'signing-tools') - $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.' } + foreach ($architecture in @('x64','arm64')) { + $name = "GPConnect_${displayVersion}_windows-$architecture-setup.exe" + 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 shell: pwsh run: | @@ -115,12 +113,15 @@ jobs: $env:UPDATE_HIGHLIGHTS | Set-Content $notes -Encoding utf8NoBOM $output = Join-Path $public 'windows' $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', '--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, + $arguments = @('scripts/windows-update-feed.py', '--version', $env:PRODUCT_VERSION, '--channel', $env:UPDATE_CHANNEL, '--released-at', [DateTime]::UtcNow.ToString('yyyy-MM-dd'), '--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 ($env:BUILD_VERSION) { $arguments += @('--build', $env:BUILD_VERSION) } python @arguments diff --git a/scripts/gh-release.sh b/scripts/gh-release.sh index 5245db4..67fce6e 100755 --- a/scripts/gh-release.sh +++ b/scripts/gh-release.sh @@ -175,7 +175,7 @@ release_snapshot() { # The appcast publisher removes expired macOS snapshots after the new 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 fi if ! delete_release_asset "$asset"; then diff --git a/scripts/private-ci-diagnostics.py b/scripts/private-ci-diagnostics.py index f6c1c58..a62f7bc 100644 --- a/scripts/private-ci-diagnostics.py +++ b/scripts/private-ci-diagnostics.py @@ -8,6 +8,18 @@ import sys 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))) if codes: print(f'::error::Rust diagnostic codes: {" ".join(codes)}.') @@ -17,6 +29,10 @@ def report_compile(output): 'compiler or linker killed by SIGKILL'), (r'undefined reference to|undefined symbol:', 'unresolved linker symbols'), ('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: if re.search(pattern, output): diff --git a/scripts/test-windows-installer.ps1 b/scripts/test-windows-installer.ps1 new file mode 100644 index 0000000..9ec56e1 --- /dev/null +++ b/scripts/test-windows-installer.ps1 @@ -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." diff --git a/scripts/tests/test_private_ci.py b/scripts/tests/test_private_ci.py index a233748..a393b98 100644 --- a/scripts/tests/test_private_ci.py +++ b/scripts/tests/test_private_ci.py @@ -274,6 +274,23 @@ class PrivateTestStageTests(unittest.TestCase): self.assertIn(expected, result.stdout) 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): with tempfile.TemporaryDirectory() as temporary: log = Path(temporary) / 'private.log' diff --git a/scripts/tests/test_windows_update_feed.py b/scripts/tests/test_windows_update_feed.py index 525991c..5996efa 100644 --- a/scripts/tests/test_windows_update_feed.py +++ b/scripts/tests/test_windows_update_feed.py @@ -22,17 +22,17 @@ preserver = load("preserve_update_feeds", "preserve-update-feeds.py") class WindowsFeedTests(unittest.TestCase): - def args(self, root, channel="stable", version="3.4.0", build=None): - name = feed.installer_name(version, channel, build) + def args(self, root, channel="stable", version="3.4.0", build=None, architecture="x64"): + name = feed.installer_name(version, channel, build, architecture) installer = root / name - installer.write_bytes(b"test installer") - signature = root / "installer.sig" - signature.write_text(base64.b64encode(bytes(64)).decode()) + installer.write_bytes(f"test installer {architecture}".encode()) + signature = root / f"installer-{architecture}.sig" + signature.write_text(base64.b64encode(bytes([1 if architecture == "arm64" else 0]) * 64).decode()) highlights = root / "highlights.txt" highlights.write_text("Update & improve .\n") tag = f"v{version}" if channel == "stable" else "snapshot" - return argparse.Namespace(installer=installer, signature_file=signature, - installer_url=f"https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{tag}/{name}", + return argparse.Namespace(payload=[feed.Payload(architecture, installer, + f"https://github.com/yuezk/GlobalProtect-openconnect/releases/download/{tag}/{name}", signature)], repository="yuezk/GlobalProtect-openconnect", channel=channel, version=version, build=build, released_at="2026-11-14", 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 .") enclosure = item.find("enclosure") 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") + 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): with tempfile.TemporaryDirectory() as directory: args = self.args(Path(directory)) feed.generate(args) args.input = args.output / "latest.json" 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.installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.installer.name}" + args.payload[0].installer = args.payload[0].installer.rename(args.payload[0].installer.parent / feed.installer_name(args.version, args.channel, args.build)) + args.payload[0].installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.payload[0].installer.name}" feed.generate(args) catalog = json.loads(args.input.read_text()) 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") self.assertEqual(enclosure.get(f"{{{feed.SPARKLE}}}version"), "3.4.0-snapshot.2026.1114.2") args.build = "2026.1114.1" - args.installer = args.installer.rename(args.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 = args.payload[0].installer.rename(args.payload[0].installer.parent / feed.installer_name(args.version, args.channel, args.build)) + args.payload[0].installer_url = f"https://github.com/{args.repository}/releases/download/snapshot/{args.payload[0].installer.name}" with self.assertRaisesRegex(ValueError, "older"): feed.generate(args) @@ -91,7 +123,7 @@ class WindowsFeedTests(unittest.TestCase): for channel in ("stable", "snapshot"): 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("url"), stable.installer_url) + self.assertEqual(enclosure.get("url"), stable.payload[0].installer_url) def test_stable_without_snapshot_initializes_both_native_feeds(self): with tempfile.TemporaryDirectory() as directory: @@ -130,7 +162,7 @@ class WindowsFeedTests(unittest.TestCase): def test_private_loopback_download_requires_explicit_opt_in(self): with tempfile.TemporaryDirectory() as 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"): feed.generate(args) args.allow_localhost = True @@ -139,7 +171,7 @@ class WindowsFeedTests(unittest.TestCase): def test_missing_or_malformed_signature_is_rejected(self): with tempfile.TemporaryDirectory() as 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): feed.generate(args) diff --git a/scripts/windows-update-feed.py b/scripts/windows-update-feed.py index 9e3a2ab..0b9d339 100644 --- a/scripts/windows-update-feed.py +++ b/scripts/windows-update-feed.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 -"""Build the Windows catalog and WinSparkle appcast from one verified installer.""" -from __future__ import annotations - +"""Build one Windows catalog and appcast from verified native installers.""" import argparse import base64 +from dataclasses import dataclass import hashlib import importlib.util import json @@ -18,14 +17,47 @@ manifest = importlib.util.module_from_spec(spec) 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: if channel == "snapshot": return f"{version}-snapshot.{build}" return version -def installer_name(version: str, channel: str, build: str | None) -> str: - return f"GPConnect_{release_version(version, channel, build)}_windows-x64-setup.exe" +def installer_name(version: str, channel: str, build: str | None, architecture: str = "x64") -> str: + 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: @@ -36,25 +68,9 @@ def generate(args: argparse.Namespace) -> None: manifest.build_tuple(args.build) elif args.build is not None: raise ValueError("stable releases must not specify --build") - expected_name = installer_name(args.version, args.channel, args.build) - if not args.allow_localhost and args.installer.name != expected_name: - raise ValueError("installer filename does not match the version, channel and build") - 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 not args.payload or len({payload.architecture for payload in args.payload}) != len(args.payload): + raise ValueError("provide one installer per Windows architecture") + prepared = [(payload, *validate_payload(payload, args)) for payload in args.payload] 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) stable = previous["stable"] @@ -76,40 +92,40 @@ def generate(args: argparse.Namespace) -> None: rss = ET.Element("rss", {"version": "2.0"}) channel = ET.SubElement(rss, "channel") ET.SubElement(channel, "title").text = "GP Connect for Windows" - item = ET.SubElement(channel, "item") - ET.SubElement(item, "title").text = f"GP Connect {display_version}" - ET.SubElement(item, "description").text = "\n".join(release["highlights"]) - ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = "10.0.19041" - ET.SubElement(item, "enclosure", { - "url": args.installer_url, "length": str(length), "type": "application/octet-stream", - f"{{{SPARKLE}}}version": display_version, - f"{{{SPARKLE}}}shortVersionString": display_version, - f"{{{SPARKLE}}}os": "windows-x64", f"{{{SPARKLE}}}edSignature": signature, - }) + for payload, signature, length in prepared: + item = ET.SubElement(channel, "item") + ET.SubElement(item, "title").text = f"GP Connect {display_version}" + ET.SubElement(item, "description").text = "\n".join(release["highlights"]) + minimum = "10.0.22000" if payload.architecture == "arm64" else "10.0.19041" + ET.SubElement(item, f"{{{SPARKLE}}}minimumSystemVersion").text = minimum + ET.SubElement(item, "enclosure", { + "url": payload.installer_url, "length": str(length), "type": "application/octet-stream", + f"{{{SPARKLE}}}version": display_version, + f"{{{SPARKLE}}}shortVersionString": display_version, + f"{{{SPARKLE}}}os": f"windows-{payload.architecture}", f"{{{SPARKLE}}}edSignature": signature, + }) ET.indent(rss) channels = [args.channel] snapshot = data["snapshot"] if args.channel == "stable" and ( snapshot is None or manifest.version_tuple(args.version) > manifest.version_tuple(snapshot["baseVersion"]) ): - # Core offers a newer stable release to snapshot installations too. - # Keep the snapshot catalog history, but route its native install feed - # to the same newer stable candidate until a new snapshot is promoted. + # A newer stable release also updates snapshot installations. channels.append("snapshot") for target_channel in channels: channel_directory = output / target_channel channel_directory.mkdir(exist_ok=True) ET.ElementTree(rss).write(channel_directory / "appcast.xml", encoding="utf-8", xml_declaration=True) - with args.installer.open("rb") as installer: - digest = hashlib.file_digest(installer, "sha256").hexdigest() - (output / (args.installer.name + ".sha256")).write_text(f"{digest} {args.installer.name}\n", encoding="ascii") + for payload, _, _ in prepared: + with payload.installer.open("rb") as installer: + 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: parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--installer", type=Path, required=True) - parser.add_argument("--installer-url", required=True) - parser.add_argument("--signature-file", type=Path, required=True) + parser.add_argument("--payload", nargs=4, action="append", required=True, + metavar=("ARCH", "INSTALLER", "URL", "SIGNATURE_FILE")) parser.add_argument("--repository", default="yuezk/GlobalProtect-openconnect") parser.add_argument("--channel", choices=("stable", "snapshot"), 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("--allow-localhost", action="store_true", help="Permit an isolated loopback test download") args = parser.parse_args() + args.payload = [Payload(architecture, Path(installer), url, Path(signature)) + for architecture, installer, url, signature in args.payload] try: generate(args) except (OSError, ValueError) as error: From 029f292a6d030a381cac3b6391b64aa73ccae5b7 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 15 Nov 2026 02:56:43 +0800 Subject: [PATCH 6/9] fix(ci): identify the release feed publisher in HTTP requests (#708) --- scripts/preserve-update-feeds.py | 6 ++++-- scripts/tests/test_windows_update_feed.py | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/preserve-update-feeds.py b/scripts/preserve-update-feeds.py index ff6131a..5053cc0 100644 --- a/scripts/preserve-update-feeds.py +++ b/scripts/preserve-update-feeds.py @@ -5,7 +5,7 @@ import json from pathlib import Path from urllib.error import HTTPError from urllib.parse import urlparse -from urllib.request import urlopen +from urllib.request import Request, urlopen import xml.etree.ElementTree as ET FEEDS = ("appcast.xml", "latest.json", "windows/latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml") @@ -18,7 +18,9 @@ def preserve(base_url: str, directory: Path, exclude: list[str]) -> None: if relative in exclude: continue try: - with urlopen(base_url.rstrip("/") + "/" + relative, timeout=30) as response: + request = Request(base_url.rstrip("/") + "/" + relative, + headers={"User-Agent": "GPConnectReleasePublisher/1.0"}) + with urlopen(request, timeout=30) as response: data = response.read(1024 * 1024 + 1) except HTTPError as error: if error.code == 404: diff --git a/scripts/tests/test_windows_update_feed.py b/scripts/tests/test_windows_update_feed.py index 5996efa..6ac8f3b 100644 --- a/scripts/tests/test_windows_update_feed.py +++ b/scripts/tests/test_windows_update_feed.py @@ -187,6 +187,9 @@ class WindowsFeedTests(unittest.TestCase): ["appcast.xml", "latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml"]) self.assertTrue((root / "windows/latest.json").exists()) self.assertEqual(request.call_count, 1) + outgoing = request.call_args.args[0] + self.assertEqual(outgoing.full_url, "https://updates.gpgui.com/windows/latest.json") + self.assertEqual(outgoing.get_header("User-agent"), "GPConnectReleasePublisher/1.0") with patch.object(preserver, "urlopen", side_effect=HTTPError("url", 500, "failure", {}, None)): with self.assertRaises(HTTPError): preserver.preserve("https://updates.gpgui.com", root, []) From 76310f14949398bf375bcc89fea25f1d216e7068 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 15 Nov 2026 03:05:54 +0800 Subject: [PATCH 7/9] fix(ci): wait for Windows update feed propagation (#709) --- .../workflows/publish-windows-update-feed.yaml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-windows-update-feed.yaml b/.github/workflows/publish-windows-update-feed.yaml index 8a981c0..085f36e 100644 --- a/.github/workflows/publish-windows-update-feed.yaml +++ b/.github/workflows/publish-windows-update-feed.yaml @@ -146,7 +146,17 @@ jobs: foreach ($relative in $feeds) { $expected = [IO.File]::ReadAllBytes((Join-Path 'gpgui/apps/update-feed-worker/public/windows' $relative)) $downloaded = Join-Path $env:RUNNER_TEMP ('published-' + ($relative -replace '/', '-')) - Invoke-WebRequest "https://updates.gpgui.com/windows/$relative" -OutFile $downloaded - $actual = [IO.File]::ReadAllBytes($downloaded) - if ([Convert]::ToBase64String($expected) -ne [Convert]::ToBase64String($actual)) { throw "Published feed does not match: $relative" } + $matched = $false + foreach ($attempt in 1..10) { + try { + Invoke-WebRequest "https://updates.gpgui.com/windows/$relative" -UserAgent 'GPConnectReleasePublisher/1.0' -OutFile $downloaded + $actual = [IO.File]::ReadAllBytes($downloaded) + $matched = [Convert]::ToBase64String($expected) -eq [Convert]::ToBase64String($actual) + } catch { + Write-Host "Waiting for published feed: $relative ($attempt/10)" + } + if ($matched) { break } + if ($attempt -lt 10) { Start-Sleep -Seconds 3 } + } + if (!$matched) { throw "Published feed does not match: $relative" } } From a43785792a3381154bf6a8b6746e7a180fd9b336 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 15 Nov 2026 09:21:23 +0800 Subject: [PATCH 8/9] fix(ci): retain the verified Unix build during macOS retry promotion (#710) --- .github/workflows/publish-update-feeds.yaml | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-update-feeds.yaml b/.github/workflows/publish-update-feeds.yaml index bdda15d..f94f171 100644 --- a/.github/workflows/publish-update-feeds.yaml +++ b/.github/workflows/publish-update-feeds.yaml @@ -34,6 +34,10 @@ on: highlights: required: false type: string + unix_snapshot_build: + description: Verified Unix snapshot build when it differs from the macOS retry + required: false + type: string unix_platforms: required: false default: linux,freebsd,openbsd @@ -75,6 +79,10 @@ on: description: Stable release highlights, one per line required: false type: string + unix_snapshot_build: + description: Verified Unix snapshot build; omit when it matches the macOS build + required: false + type: string unix_platforms: description: Comma-separated Unix platforms with published assets (linux,freebsd,openbsd) required: true @@ -104,6 +112,7 @@ jobs: SPARKLE_VERSION: 2.9.2 UPDATE_HIGHLIGHTS: ${{ inputs.highlights }} UNIX_PLATFORMS: ${{ inputs.unix_platforms }} + UNIX_SNAPSHOT_BUILD: ${{ inputs.unix_snapshot_build }} SPARKLE_ARCHIVE_SHA256: b83e37436774556ed055e0244b297ef2c790e0737393bf65bf495fcbba6eed65 steps: - name: Validate inputs @@ -126,6 +135,12 @@ jobs: echo "unix_platforms must list published Unix targets separated by commas" >&2 exit 1 fi + if [[ -n "$UNIX_SNAPSHOT_BUILD" ]]; then + if [[ "$CHANNEL" != "snapshot" || ! "$UNIX_SNAPSHOT_BUILD" =~ ^(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*)){0,2}$ ]]; then + echo "unix_snapshot_build requires a snapshot channel and one to three numeric components" >&2 + exit 1 + fi + fi if [[ "$CHANNEL" == "snapshot" && "$RELEASE_TAG" != "snapshot" ]]; then echo "The snapshot channel must publish to the snapshot release" >&2 exit 1 @@ -344,6 +359,7 @@ jobs: echo "short_version=$short_version" >> "$GITHUB_OUTPUT" - name: Prepare Unix update manifest + id: unix_manifest env: RELEASED_AT: ${{ steps.release.outputs.released_at }} run: | @@ -384,7 +400,8 @@ jobs: else printf 'Development snapshot after %s.\n' \ "${{ steps.bundle.outputs.short_version }}" > "$highlights" - generate_args+=(--build "${{ steps.bundle.outputs.version }}") + unix_build="${UNIX_SNAPSHOT_BUILD:-${{ steps.bundle.outputs.version }}}" + generate_args+=(--build "$unix_build") released_at="$(date -u +%F)" fi @@ -393,6 +410,9 @@ jobs: --released-at "$released_at" \ --highlights-file "$highlights" \ --output "$manifest" + if [[ "$CHANNEL" == "snapshot" ]]; then + echo "build=$unix_build" >> "$GITHUB_OUTPUT" + fi - name: Fetch current appcast id: current-appcast @@ -588,7 +608,7 @@ jobs: --version "${{ steps.bundle.outputs.short_version }}" ) if [[ "$CHANNEL" == "snapshot" ]]; then - expected+=(--build "${{ steps.bundle.outputs.version }}") + expected+=(--build "${{ steps.unix_manifest.outputs.build }}") fi for _ in 1 2 3 4 5 6 7 8 9 10; do if curl --fail --location --silent --show-error \ From 1072a35817bba2b493a6773dde534a1d9b4a7c82 Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Sun, 15 Nov 2026 10:26:35 +0800 Subject: [PATCH 9/9] ci: publish only Windows installers and their verification files (#711) --- .github/workflows/build-windows.yaml | 5 ++--- .github/workflows/build.yaml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-windows.yaml b/.github/workflows/build-windows.yaml index b80d3d2..f5313a5 100644 --- a/.github/workflows/build-windows.yaml +++ b/.github/workflows/build-windows.yaml @@ -179,9 +179,8 @@ jobs: name: artifact-gpgui-windows-${{ inputs.architecture }} path: | artifacts/*.exe - artifacts/*.sig - artifacts/*.sha256 - artifacts/*.zip + artifacts/*.exe.sig + artifacts/*.exe.sha256 overwrite: true if-no-files-found: error retention-days: 7 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d477aaf..17f6dfe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -43,7 +43,7 @@ on: default: false type: boolean build_windows: - description: 'Build Windows x64 and ARM64 NSH installers and development ZIPs' + description: 'Build Windows x64 and ARM64 NSH installers' required: true default: false type: boolean