feat: build and smoke test native Windows ARM64 packages

This commit is contained in:
Kevin Yue committed 2026-11-15 00:25:34 +08:00
1 parent 87fdcc76b3
commit de9656fcd2
10 files changed
+139 -22

No files matched your search

+50 -10
View File
@@ -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,7 +135,7 @@ 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
@@ -129,13 +163,19 @@ 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
with:
name: artifact-gpgui-windows-x64
name: artifact-gpgui-windows-${{ inputs.architecture }}
path: |
artifacts/*.exe
artifacts/*.sig
artifacts/*.sha256
artifacts/*.zip
if-no-files-found: error
retention-days: 14
retention-days: 7
+5
View File
@@ -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' }}
+1 -1
View File
@@ -366,7 +366,7 @@ mod tests {
r#"{"version":1,"anchor":{"hardware_id":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","source":1}}"#
);
for source in [0, 4] {
for source in [0, u8::MAX] {
let json = serde_json::json!({
"version": 1,
"anchor": {
+16 -2
View File
@@ -12,6 +12,9 @@ RequestExecutionLevel admin
!ifndef PRODUCT_VERSION
!error "PRODUCT_VERSION is required"
!endif
!ifndef TARGET_ARCH
!define TARGET_ARCH "x64"
!endif
!ifndef BUILD_VERSION
!define BUILD_VERSION "${PRODUCT_VERSION}.0"
!endif
@@ -43,10 +46,21 @@ ShowUninstDetails show
!insertmacro MUI_LANGUAGE "English"
Function .onInit
${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONSTOP "GP Connect requires 64-bit Windows."
!if "${TARGET_ARCH}" == "arm64"
${IfNot} ${IsNativeARM64}
MessageBox MB_OK|MB_ICONSTOP "This GP Connect installer requires Windows 11 on ARM64." /SD IDOK
SetErrorLevel 1
Abort
${EndIf}
!else if "${TARGET_ARCH}" == "x64"
${IfNot} ${IsNativeAMD64}
MessageBox MB_OK|MB_ICONSTOP "This GP Connect installer requires x64 Windows." /SD IDOK
SetErrorLevel 1
Abort
${EndIf}
!else
!error "Unsupported TARGET_ARCH"
!endif
SetRegView 64
FunctionEnd
+6 -2
View File
@@ -232,11 +232,15 @@ try {
throw 'Use the Windows installer to update this installation.'
}
if (!$Version) { $Version = $info.version }
if ($info.product -ne 'GP Connect' -or $info.architecture -ne 'x64' -or !$Version -or $info.version -ne $Version) {
$architecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()
if ($info.product -ne 'GP Connect' -or $info.architecture -notin @('x64','arm64') -or $info.architecture -ne $architecture -or !$Version -or $info.version -ne $Version) {
throw 'The package version or architecture does not match this installer.'
}
if (![Environment]::Is64BitProcess -or [Environment]::OSVersion.Version.Build -lt 19041) {
throw 'GP Connect requires Windows 10 build 19041 or newer, x64.'
throw 'GP Connect requires Windows 10 build 19041 or newer.'
}
if ($architecture -eq 'arm64' -and [Environment]::OSVersion.Version.Build -lt 22000) {
throw 'GP Connect for ARM64 requires Windows 11.'
}
$payload = @(Get-ChildItem -LiteralPath $source -Force | Where-Object {
($_.PSIsContainer -and $_.Name -eq 'licenses') -or
+10 -4
View File
@@ -3,7 +3,7 @@
[CmdletBinding()]
param(
[string]$MsysRoot = 'C:\msys64',
[ValidateSet('mingw64','ucrt64')][string]$MsysSubsystem = 'mingw64',
[ValidateSet('mingw64','ucrt64','clangarm64')][string]$MsysSubsystem = 'mingw64',
[string]$Prefix,
[int]$Jobs = 4
)
@@ -19,10 +19,16 @@ $nativeExit = $LASTEXITCODE
$ErrorActionPreference = 'Stop'
if ($nativeExit -ne 0) { throw 'OpenConnect compilation failed.' }
$architecture = 'x64'
if ($MsysSubsystem -eq 'clangarm64') { $architecture = 'arm64' }
$component = 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64'
if ($architecture -eq 'arm64') { $component = 'Microsoft.VisualStudio.Component.VC.Tools.ARM64' }
$hostTools = 'Hostx64'
if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $hostTools = 'Hostarm64' }
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vs = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
$vs = & $vswhere -latest -products '*' -requires $component -property installationPath
if (!$vs) { throw 'Visual Studio C++ Build Tools are required.' }
$tools = (Get-ChildItem "$vs\VC\Tools\MSVC\*\bin\Hostx64\x64\lib.exe" |
$tools = (Get-ChildItem "$vs\VC\Tools\MSVC\*\bin\$hostTools\$architecture\lib.exe" |
Sort-Object FullName | Select-Object -Last 1).DirectoryName
$dll = Join-Path $Prefix 'bin\libopenconnect-5.dll'
$exports = & "$tools\dumpbin.exe" /nologo /exports $dll
@@ -35,7 +41,7 @@ foreach ($symbol in @('openconnect_setup_cmd_pipe', 'openconnect_setup_tun_pipe'
}
$definition = Join-Path $Prefix 'lib\openconnect.def'
[System.IO.File]::WriteAllLines($definition, @('LIBRARY libopenconnect-5.dll', 'EXPORTS') + $names)
& "$tools\lib.exe" /nologo /machine:x64 "/def:$definition" "/out:$Prefix\lib\openconnect.lib"
& "$tools\lib.exe" /nologo "/machine:$architecture" "/def:$definition" "/out:$Prefix\lib\openconnect.lib"
if ($LASTEXITCODE -ne 0) { throw 'Could not generate the MSVC import library.' }
# Copy only the native DLL's transitive MinGW runtime dependencies.
+6 -1
View File
@@ -13,7 +13,12 @@ cd "$source_dir"
autoreconf -fi
mkdir -p "$build_dir"
cd "$build_dir"
"$source_dir/configure" --host=x86_64-w64-mingw32 --prefix="$prefix" \
host=x86_64-w64-mingw32
if [[ $subsystem == clangarm64 ]]; then
host=aarch64-w64-mingw32
export CC=clang AR=llvm-ar RANLIB=llvm-ranlib NM=llvm-nm
fi
"$source_dir/configure" --host="$host" --prefix="$prefix" \
--enable-shared --disable-static --disable-nls --disable-docs --disable-dsa-tests \
--without-libproxy --without-stoken --without-libpcsclite --without-libpskc \
--without-gssapi --with-gnutls --without-openssl --with-gnutls-tss2=no \
+1 -1
View File
@@ -1,6 +1,6 @@
[CmdletBinding()]
param([string]$MsysRoot = 'C:\msys64', [string]$Prefix = $env:OPENCONNECT_WINDOWS_PREFIX,
[ValidateSet('mingw64','ucrt64')][string]$MsysSubsystem = 'mingw64')
[ValidateSet('mingw64','ucrt64','clangarm64')][string]$MsysSubsystem = 'mingw64')
$repo = Split-Path $PSScriptRoot -Parent
if (!$Prefix) { $Prefix = Join-Path $repo 'target\native-windows' }
& "$MsysRoot\usr\bin\bash.exe" "$PSScriptRoot/test-openconnect-windows.sh" $repo $Prefix $MsysSubsystem
+3 -1
View File
@@ -8,7 +8,9 @@ prefix=$(cygpath -u "$2")
build_dir="$repo/target/openconnect-windows"
source_dir="$repo/crates/openconnect/deps/openconnect"
export PATH="$prefix/bin:$PATH"
gcc -Wall -Wextra -I"$build_dir" -I"$source_dir" -I"$source_dir/json" \
compiler=gcc
if [[ $subsystem == clangarm64 ]]; then compiler=clang; fi
"$compiler" -Wall -Wextra -I"$build_dir" -I"$source_dir" -I"$source_dir/json" \
$(pkg-config --cflags gnutls libxml-2.0) \
"$repo/crates/openconnect/tests/windows_packet_pipe.c" \
-L"$prefix/lib" -lopenconnect -lws2_32 -o "$build_dir/test-windows-packet-pipe.exe"
+41
View File
@@ -0,0 +1,41 @@
# 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) { throw 'The installer failed.' }
$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'
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."