Merge pull request #714 from yuezk/ci/windows-launch-release

ci: prepare signed Windows releases and snapshot promotion
This commit is contained in:
Kevin Yue authored and GitHub committed 2026-11-18 08:32:05 -08:00
commit 6ffb1e8709
10 files changed
+353 -32

No files matched your search

+4 -1
View File
@@ -12,6 +12,9 @@ on:
channel:
required: true
type: string
build:
required: true
type: string
builder:
required: true
type: string
@@ -85,7 +88,7 @@ jobs:
- name: Build gpgui in Docker
env:
GPGUI_BUILDER: ${{ inputs.builder }}
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
GPGUI_BUILD_VERSION: ${{ inputs.build }}
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
run: |
+4 -1
View File
@@ -12,6 +12,9 @@ on:
channel:
required: true
type: string
build:
required: true
type: string
secrets:
GH_PAT:
required: true
@@ -35,7 +38,7 @@ jobs:
env:
CARGO_INCREMENTAL: '0'
CARGO_BUILD_JOBS: '2'
GPGUI_BUILD_VERSION: ${{ github.run_number }}.${{ github.run_attempt }}
GPGUI_BUILD_VERSION: ${{ inputs.build }}
GPGUI_GIT_COMMIT: ${{ inputs.gpgui_ref }}
GPGUI_UPDATE_CHANNEL: ${{ inputs.channel }}
GPGUI_LICENSE_SIGNING_KEYS: ${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}
+31 -4
View File
@@ -49,6 +49,10 @@ permissions:
jobs:
build:
runs-on: ${{ inputs.architecture == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
environment: windows-signing
permissions:
contents: read
id-token: write
timeout-minutes: 120
env:
BUILD_ARCHITECTURE: ${{ inputs.architecture }}
@@ -59,6 +63,10 @@ jobs:
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 }}
AZURE_SIGNING_ENDPOINT: ${{ vars.AZURE_SIGNING_ENDPOINT }}
AZURE_SIGNING_ACCOUNT: ${{ vars.AZURE_SIGNING_ACCOUNT }}
AZURE_SIGNING_PROFILE: ${{ vars.AZURE_SIGNING_PROFILE }}
WINDOWS_SIGNING_PUBLISHER: ${{ vars.WINDOWS_SIGNING_PUBLISHER }}
steps:
- name: Select native build tools
id: native
@@ -125,7 +133,7 @@ jobs:
& ./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
- name: Build the matching Windows runtime
shell: pwsh
env:
MSYS_ROOT: ${{ steps.msys2.outputs.msys2-location }}
@@ -134,16 +142,35 @@ jobs:
$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 `
& ./source/gpgui/scripts/build-windows.ps1 -Profile Release -BuildOnly `
-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 {
python ./.ci/scripts/private-ci-diagnostics.py compile $log
throw 'Windows compilation or packaging failed; private diagnostics remain on the runner.'
throw 'Windows compilation failed; private diagnostics remain on the runner.'
}
Write-Host 'Windows compilation and packaging passed.'
Write-Host 'Windows compilation passed.'
- name: Install Microsoft Artifact Signing tooling
shell: pwsh
run: Install-Module ArtifactSigning -RequiredVersion 0.1.20 -Repository PSGallery -Force -Scope CurrentUser
- name: Log in to Azure with GitHub OIDC
uses: azure/login@v3
with:
client-id: ${{ vars.AZURE_SIGNING_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Sign and package the Windows runtime
shell: pwsh
env:
MSYS_ROOT: ${{ steps.msys2.outputs.msys2-location }}
run: |
& ./source/gpgui/scripts/build-windows.ps1 -Profile Release -SkipBuild -Sign `
-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"
- name: Sign and verify update payload
id: sign
shell: pwsh
+74 -11
View File
@@ -69,8 +69,10 @@ jobs:
actions: read
contents: read
outputs:
gp_sha: ${{ steps.sources.outputs.gp_sha }}
gpgui_sha: ${{ steps.sources.outputs.gpgui_sha }}
gp_sha: ${{ steps.identity.outputs.gp_sha }}
gpgui_sha: ${{ steps.identity.outputs.gpgui_sha }}
version: ${{ steps.identity.outputs.version }}
build_version: ${{ steps.identity.outputs.build_version }}
steps:
- name: Validate stable refs
env:
@@ -119,11 +121,12 @@ jobs:
token: ${{ secrets.GH_PAT }}
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.gpgui_branch || github.ref_name }}
path: selected/gpgui
- name: Record selected sources
id: sources
- name: Record selected sources and versions
id: identity
run: |
python3 scripts/record-build-sources.py selected-sources/sources.json \
--gp selected/gp --gpgui selected/gpgui
--gp selected/gp --gpgui selected/gpgui \
--build-version "${{ github.run_number }}.${{ github.run_attempt }}"
- name: Retain selected sources for retries
if: steps.restored.outputs.cached != 'true'
uses: actions/upload-artifact@v7
@@ -442,6 +445,7 @@ jobs:
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: ${{ needs.validate-inputs.outputs.build_version }}
builder: gpgui-builder-tauri2
verify_desktop_assets: true
secrets:
@@ -455,6 +459,7 @@ jobs:
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: ${{ needs.validate-inputs.outputs.build_version }}
builder: gpgui-alpine-builder-tauri2
artifact_suffix: -musl
secrets:
@@ -467,11 +472,15 @@ jobs:
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: ${{ needs.validate-inputs.outputs.build_version }}
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
build-windows:
needs: validate-inputs
permissions:
contents: read
id-token: write
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_windows) || (startsWith(github.ref, 'refs/tags/') && vars.BUILD_WINDOWS_ON_TAG == 'true') }}
strategy:
fail-fast: false
@@ -483,7 +492,7 @@ jobs:
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) }}
build: ${{ needs.validate-inputs.outputs.build_version }}
secrets:
GH_PAT: ${{ secrets.GH_PAT }}
WINDOWS_UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }}
@@ -682,7 +691,7 @@ jobs:
FEED_URL: ${{ vars.SPARKLE_FEED_URL }}
CHANNEL: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel || 'stable') }}
RELEASE_TAG: ${{ (github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name) }}
BUILD_VERSION: ${{ format('{0}.{1}', github.run_number, github.run_attempt) }}
BUILD_VERSION: ${{ needs.validate-inputs.outputs.build_version }}
run: |
set -euo pipefail
@@ -850,7 +859,7 @@ jobs:
CHANNEL: ${{ (github.event_name == 'workflow_dispatch' && inputs.channel || 'stable') }}
RELEASE_TAG: ${{ (github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name) }}
REQUEST_ID: ${{ format('{0}.{1}.macos', github.run_id, github.run_attempt) }}
BUILD_VERSION: ${{ format('{0}.{1}', github.run_number, github.run_attempt) }}
BUILD_VERSION: ${{ needs.validate-inputs.outputs.build_version }}
WORKFLOW_SHA: ${{ github.sha }}
run: |
set -euo pipefail
@@ -1049,7 +1058,6 @@ jobs:
nettle \
gmp \
gnome-keyring \
libayatana-appindicator \
polkit \
webkit2-gtk_41
pkgconf --exists libxml-2.0 liblz4 gnutls p11-kit-1 hogweed nettle gmp
@@ -1058,7 +1066,7 @@ jobs:
exec 3>&1
(
set -eu
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
export GPGUI_BUILD_VERSION=${{ needs.validate-inputs.outputs.build_version }}
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
@@ -1142,7 +1150,7 @@ jobs:
set -eu
export AUTOCONF_VERSION=2.72
export AUTOMAKE_VERSION=1.17
export GPGUI_BUILD_VERSION=${{ github.run_number }}.${{ github.run_attempt }}
export GPGUI_BUILD_VERSION=${{ needs.validate-inputs.outputs.build_version }}
export GPGUI_UPDATE_CHANNEL=${{ github.event_name == 'workflow_dispatch' && inputs.channel || 'stable' }}
export GPGUI_LICENSE_SIGNING_KEYS='${{ vars.GPGUI_LICENSE_SIGNING_KEYS }}'
@@ -1313,6 +1321,61 @@ jobs:
run: |
cd gh-release/gp/scripts && ./gh-release.sh "$RELEASE_TAG"
publish-macos-assets:
needs: [build-macos, gh-release]
if: >-
${{ !cancelled() &&
needs.build-macos.result == 'success' && needs.gh-release.result == 'success' }}
permissions:
actions: read
contents: write
uses: ./.github/workflows/publish-macos-assets.yaml
with:
build_run_id: ${{ github.run_id }}
release_tag: ${{ github.event_name == 'workflow_dispatch' && (inputs.channel == 'stable' && inputs.gp_branch || 'snapshot') || github.ref_name }}
expected_gui: ${{ github.event_name == 'workflow_dispatch' && inputs.macos_gui || 'nsh' }}
secrets: inherit
publish-windows-snapshot-feed:
needs: [validate-inputs, gh-release, publish-macos-assets]
if: >-
${{ !cancelled() && github.event_name == 'workflow_dispatch' &&
inputs.channel == 'snapshot' && !inputs.build_only && inputs.build_windows &&
needs.gh-release.result == 'success' &&
(!inputs.build_macos || needs.publish-macos-assets.result == 'success') }}
permissions:
contents: read
uses: ./.github/workflows/publish-windows-update-feed.yaml
with:
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
release_tag: snapshot
version: ${{ needs.validate-inputs.outputs.version }}
channel: snapshot
build: ${{ needs.validate-inputs.outputs.build_version }}
highlights: Development snapshot.
secrets: inherit
publish-macos-unix-snapshot-feeds:
needs: [validate-inputs, gh-release, publish-macos-assets, publish-windows-snapshot-feed]
if: >-
${{ !cancelled() && github.event_name == 'workflow_dispatch' &&
inputs.channel == 'snapshot' && !inputs.build_only && inputs.build_macos &&
needs.gh-release.result == 'success' && needs.publish-macos-assets.result == 'success' &&
(!inputs.build_windows || needs.publish-windows-snapshot-feed.result == 'success') }}
permissions:
contents: write
uses: ./.github/workflows/publish-update-feeds.yaml
with:
gpgui_ref: ${{ needs.validate-inputs.outputs.gpgui_sha }}
gp_ref: ${{ needs.validate-inputs.outputs.gp_sha }}
channel: snapshot
release_tag: snapshot
archive_name: ${{ format('GPConnect_{0}-snapshot.{1}_arm64.zip', needs.validate-inputs.outputs.version, needs.validate-inputs.outputs.build_version) }}
expected_gui: ${{ inputs.macos_gui }}
unix_platforms: ${{ (inputs.build_bsd || inputs.build_bsd_arm64) && 'linux,freebsd,openbsd' || 'linux' }}
highlights: Development snapshot.
secrets: inherit
publish-docker-image:
needs:
- validate-inputs
-1
View File
@@ -54,7 +54,6 @@ jobs:
gettext \
gmp \
gnutls \
libappindicator-gtk3 \
libp11-kit \
libsecret \
libtool \
@@ -1,6 +1,21 @@
name: Publish macOS assets
on:
workflow_call:
inputs:
build_run_id:
required: true
type: string
release_tag:
required: true
type: string
expected_gui:
required: false
default: nsh
type: string
secrets:
GH_PAT:
required: false
workflow_dispatch:
inputs:
build_run_id:
@@ -1,6 +1,33 @@
name: Publish Windows update feed
on:
workflow_call:
inputs:
gpgui_ref:
required: true
type: string
release_tag:
required: true
type: string
version:
required: true
type: string
channel:
required: true
type: string
build:
required: true
type: string
highlights:
required: true
type: string
secrets:
GH_PAT:
required: true
CLOUDFLARE_ACCOUNT_ID:
required: false
CLOUDFLARE_API_TOKEN:
required: false
workflow_dispatch:
inputs:
gpgui_ref:
@@ -0,0 +1,93 @@
name: Verify public Windows release
on:
workflow_dispatch:
inputs:
release_tag:
description: Published snapshot or stable release tag
required: true
type: string
version:
description: Base product version
required: true
type: string
build:
description: Numeric snapshot build; empty for stable
type: string
gpgui_ref:
description: Matching GUI source ref containing the pinned update tools
required: true
default: release/next
type: string
permissions:
contents: read
jobs:
verify:
strategy:
fail-fast: false
matrix:
architecture: [x64, arm64]
runs-on: ${{ matrix.architecture == 'arm64' && 'windows-11-arm' || 'windows-2022' }}
timeout-minutes: 20
env:
RELEASE_TAG: ${{ inputs.release_tag }}
PRODUCT_VERSION: ${{ inputs.version }}
BUILD_VERSION: ${{ inputs.build }}
ARCHITECTURE: ${{ matrix.architecture }}
WINDOWS_UPDATE_PUBLIC_KEY: ${{ vars.WINDOWS_UPDATE_PUBLIC_KEY }}
WINDOWS_SIGNING_PUBLISHER: ${{ vars.WINDOWS_SIGNING_PUBLISHER }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.release_tag == 'snapshot' && 'release/next' || inputs.release_tag }}
persist-credentials: false
- uses: ./.github/actions/checkout-private
with:
token: ${{ secrets.GH_PAT }}
ref: ${{ inputs.gpgui_ref }}
path: gpgui
- name: Download, verify, install and uninstall the public installer
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
if ($env:PRODUCT_VERSION -notmatch '^\d+\.\d+\.\d+$') { throw 'Invalid product version.' }
if (!$env:WINDOWS_UPDATE_PUBLIC_KEY -or !$env:WINDOWS_SIGNING_PUBLISHER) { throw 'Configure the update key and signing publisher.' }
$displayVersion = $env:PRODUCT_VERSION
if ($env:RELEASE_TAG -eq 'snapshot') {
if ($env:BUILD_VERSION -notmatch '^\d+(\.\d+){0,2}$') { throw 'Invalid snapshot build.' }
$displayVersion += "-snapshot.$env:BUILD_VERSION"
} elseif ($env:RELEASE_TAG -ne "v$env:PRODUCT_VERSION" -or $env:BUILD_VERSION) { throw 'Stable release identity does not match.' }
$name = "GPConnect_${displayVersion}_windows-$env:ARCHITECTURE-setup.exe"
$downloads = Join-Path $env:RUNNER_TEMP 'public-windows-release'
New-Item -ItemType Directory $downloads | Out-Null
foreach ($asset in @($name, "$name.sha256", "$name.sig")) {
gh release download $env:RELEASE_TAG --repo $env:GITHUB_REPOSITORY --pattern $asset --dir $downloads
if ($LASTEXITCODE -ne 0) { throw "Could not download $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 checksum file.' }
$hash = (Get-FileHash $installer).Hash
if ($hash -ne $Matches[1]) { throw 'Installer checksum mismatch.' }
if ([Diagnostics.FileVersionInfo]::GetVersionInfo($installer).ProductVersion -ne $displayVersion) { throw 'Installer version mismatch.' }
& ./scripts/test-windows-signature.ps1 -Files $installer -Publisher $env:WINDOWS_SIGNING_PUBLISHER
. ./gpgui/scripts/windows-updates/Get-WinSparkle.ps1
$tools = Get-WinSparkleTools (Join-Path $env:RUNNER_TEMP 'winsparkle-tools') -Architecture $env:ARCHITECTURE
$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.' }
& ./scripts/test-windows-installer.ps1 -Installer $installer -Architecture $env:ARCHITECTURE -Build $env:BUILD_VERSION
@{ release = $env:RELEASE_TAG; version = $displayVersion; architecture = $env:ARCHITECTURE;
sha256 = $hash.ToLowerInvariant(); publisher = $env:WINDOWS_SIGNING_PUBLISHER;
authenticode = 'Valid'; timestamped = $true; update_signature = 'Valid';
installed_signatures = 'Valid'; install_uninstall = 'Passed'
} | ConvertTo-Json | Set-Content verification.json -Encoding utf8
- uses: actions/upload-artifact@v7
with:
name: windows-release-verification-${{ matrix.architecture }}
path: verification.json
if-no-files-found: error
retention-days: 30
+23 -10
View File
@@ -1,33 +1,45 @@
#!/usr/bin/env python3
"""Retain one source pair per build run so retries cannot move branch refs."""
"""Retain one source and version identity per build run, including retries."""
import argparse
import json
import os
import re
import runpy
import subprocess
from pathlib import Path
def record(path, gp, gpgui, output):
def record(path, gp, gpgui, output, build_version):
if path.exists():
sources = json.loads(path.read_text())
identity = json.loads(path.read_text())
else:
sources = {
identity = {
name: subprocess.check_output(["git", "-C", str(root), "rev-parse", "HEAD"],
text=True, stderr=subprocess.DEVNULL).strip()
for name, root in (("gp_sha", gp), ("gpgui_sha", gpgui))
}
if set(sources) != {"gp_sha", "gpgui_sha"} or any(
cargo_version = runpy.run_path(str(Path(__file__).with_name("validate-release-version.py")))["cargo_version"]
version = cargo_version(gp)
if cargo_version(gpgui) != version:
raise ValueError("public and desktop product versions differ")
identity.update(version=version, build_version=build_version)
if set(identity) != {"gp_sha", "gpgui_sha", "version", "build_version"} or any(
not isinstance(value, str) or not re.fullmatch(r"[0-9a-f]{40}", value)
for value in sources.values()
for name, value in identity.items() if name.endswith("_sha")
):
raise ValueError("invalid retained build source refs")
if not isinstance(identity["version"], str) or not re.fullmatch(r"\d+\.\d+\.\d+", identity["version"]):
raise ValueError("invalid retained product version")
if not isinstance(identity["build_version"], str) or not re.fullmatch(
r"(0|[1-9]\d*)\.(0|[1-9]\d*)", identity["build_version"]
):
raise ValueError("invalid retained build version")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(sources, indent=2) + "\n")
path.write_text(json.dumps(identity, indent=2) + "\n")
with output.open("a") as stream:
for name, sha in sources.items():
stream.write(f"{name}={sha}\n")
for name, value in identity.items():
stream.write(f"{name}={value}\n")
def main():
@@ -35,9 +47,10 @@ def main():
parser.add_argument("path", type=Path)
parser.add_argument("--gp", type=Path, required=True)
parser.add_argument("--gpgui", type=Path, required=True)
parser.add_argument("--build-version", required=True)
args = parser.parse_args()
try:
record(args.path, args.gp, args.gpgui, Path(os.environ["GITHUB_OUTPUT"]))
record(args.path, args.gp, args.gpgui, Path(os.environ["GITHUB_OUTPUT"]), args.build_version)
except (OSError, ValueError, subprocess.CalledProcessError):
parser.exit(1, "Could not retain the selected build source refs.\n")
+82 -4
View File
@@ -90,24 +90,43 @@ class ReleaseVersionTests(unittest.TestCase):
versions.validate(root, package=package)
class SourceSelectionTests(unittest.TestCase):
class BuildIdentityTests(unittest.TestCase):
def test_retry_uses_original_sources_after_both_branches_advance(self):
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
paths = [root / 'gp', root / 'gpgui']
for repo in paths:
initialize(repo)
write_version(repo)
(repo / 'source').write_text('first')
commit(repo, 'first')
path, output = root / 'sources.json', root / 'output'
sources.record(path, *paths, output)
sources.record(path, *paths, output, '42.1')
original = json.loads(path.read_text())
for repo in paths:
write_version(repo, '3.2.0')
(repo / 'source').write_text('second')
commit(repo, 'second')
sources.record(path, *paths, output)
sources.record(path, *paths, output, '42.2')
self.assertEqual(json.loads(path.read_text()), original)
self.assertEqual(output.read_text().count(f"gp_sha={original['gp_sha']}"), 2)
self.assertEqual(original['version'], '3.1.0')
self.assertEqual(original['build_version'], '42.1')
sources.record(path, root / 'missing-gp', root / 'missing-gui', output, '42.3')
self.assertEqual(json.loads(path.read_text()), original)
def test_mismatched_product_versions_are_not_retained(self):
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
paths = [root / 'gp', root / 'gpgui']
for repo, version in zip(paths, ['3.1.0', '3.2.0']):
initialize(repo)
write_version(repo, version)
commit(repo, 'source')
path = root / 'sources.json'
with self.assertRaisesRegex(ValueError, 'versions differ'):
sources.record(path, *paths, root / 'output', '42.1')
self.assertFalse(path.exists())
def test_corrupt_retained_sources_do_not_resolve_again(self):
with tempfile.TemporaryDirectory() as temp:
@@ -115,7 +134,7 @@ class SourceSelectionTests(unittest.TestCase):
path = root / 'sources.json'
path.write_text('{"gp_sha":"main","gpgui_sha":"main"}')
with self.assertRaises(ValueError):
sources.record(path, root, root, root / 'output')
sources.record(path, root, root, root / 'output', '42.1')
class PromotionTests(unittest.TestCase):
@@ -196,6 +215,65 @@ class SnapshotBranchTests(unittest.TestCase):
self.assertEqual(git(origin, 'branch', '--list', 'main'), '')
class PublicationWorkflowTests(unittest.TestCase):
def job(self, name):
source = (ROOT / '.github/workflows/build.yaml').read_text()
return re.search(r'(?ms)^ ' + name + r':\n.*?(?=^ [\w-]+:|\Z)', source).group(0)
def decisions(self, name, cases):
expression = re.search(r'\$\{\{ (.*?) \}\}', self.job(name), re.DOTALL).group(1)
expression = re.sub(r'needs\.([\w-]+)\.result', r'needs["\1"].result', expression)
script = """
const cases = JSON.parse(process.argv[1]);
const allows = new Function('needs', 'inputs', 'github', 'cancelled',
'return (' + process.argv[2] + ')');
console.log(JSON.stringify(cases.map(c => allows(c.needs, c.inputs, c.github, () => c.cancelled))));
"""
return json.loads(subprocess.check_output(
['node', '-e', script, json.dumps(cases), expression], text=True))
def test_macos_assets_require_both_jobs_and_a_live_run(self):
job = self.job('publish-macos-assets')
self.assertIn('needs: [build-macos, gh-release]', job)
self.assertIn('uses: ./.github/workflows/publish-macos-assets.yaml', job)
cases, expected = [], []
for macos in ['success', 'failure', 'skipped', 'cancelled']:
for release in ['success', 'failure', 'skipped', 'cancelled']:
for cancelled in [False, True]:
cases.append({'needs': {'build-macos': {'result': macos},
'gh-release': {'result': release}},
'inputs': {}, 'github': {}, 'cancelled': cancelled})
expected.append(not cancelled and macos == release == 'success')
self.assertEqual(self.decisions('publish-macos-assets', cases), expected)
def test_snapshot_feeds_follow_selection_and_publication_results(self):
cases, expected_windows, expected_macos = [], [], []
for macos in [False, True]:
for windows in [False, True]:
for override in [{}, {'channel': 'stable'}, {'build_only': True},
{'event': 'push'}, {'cancelled': True}, {'release': 'failure'},
{'macos_publish': 'failure'}, {'windows_feed': 'failure'}]:
inputs = dict(channel='snapshot', build_only=False,
build_macos=macos, build_windows=windows)
inputs.update({key: value for key, value in override.items() if key in inputs})
release = override.get('release', 'success')
macos_publish = override.get('macos_publish', 'success') if macos else 'skipped'
windows_feed = override.get('windows_feed', 'success') if windows else 'skipped'
cancelled = override.get('cancelled', False)
event = override.get('event', 'workflow_dispatch')
cases.append({'needs': {'gh-release': {'result': release},
'publish-macos-assets': {'result': macos_publish},
'publish-windows-snapshot-feed': {'result': windows_feed}},
'inputs': inputs, 'github': {'event_name': event}, 'cancelled': cancelled})
ready = (not cancelled and event == 'workflow_dispatch' and
inputs['channel'] == 'snapshot' and not inputs['build_only'] and
release == 'success' and (not macos or macos_publish == 'success'))
expected_windows.append(ready and windows)
expected_macos.append(ready and macos and (not windows or windows_feed == 'success'))
self.assertEqual(self.decisions('publish-windows-snapshot-feed', cases), expected_windows)
self.assertEqual(self.decisions('publish-macos-unix-snapshot-feeds', cases), expected_macos)
class DockerMatrixTests(unittest.TestCase):
def test_workflow_matrix_follows_all_architecture_choices(self):
source = (ROOT / '.github/workflows/release.yaml').read_text()