mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-22 21:23:02 +01:00
* windows: sign the setup engine so smart app control can run setup
Setup extracts a copy of its engine to %TEMP% at launch and writes the
installed uninstaller from the same bytes. Signing only the outer
hex-setup-*.exe left both unsigned, and Windows 11 Smart App Control
blocked the extracted copy ("Unable to execute file in the temporary
directory", error 4551).
SignedUninstaller embeds the engine's signature, but the signature has to
exist before the compile that uses it, and the compile job holds no
credentials. So the release signs it in two passes: the new
windows-setup-engine.yml compiles once with SignedUninstaller=yes and keeps
the unsigned uninst-*.e32 ISCC asks to be signed (ISCC leaves it and aborts
as a compile failure, exit 2); sign-windows-engine signs and verifies it in
the release environment; windows-installers.yml then compiles with the
signed engine and asserts the installed uninstaller's signature.
Test builds and runs without the Azure values keep the unsigned single
compile. Inno Setup is pinned to 6.7.1, read from the compiler's own banner
(ISCC.exe's version resource is 0.0.0), so both passes use one compiler.
* windows: harden the setup engine passes
Review fixes for the signed setup engine:
- sign-windows-engine requires sign-windows to have succeeded, and its
steps are unguarded like sign-windows-installers, so it can never upload
an empty digest.
- setup-engine runs only when Windows is signed (it waits for
sign-windows), so unsigned runs really do a single compile with no
engine pass at all.
- the Inno re-pin uses choco upgrade --allow-downgrade, because choco
install --version treats a preinstalled package as already installed.
- Invoke-Iscc collects native stderr safely under Windows PowerShell 5.1
and pwsh with $PSNativeCommandUseErrorActionPreference on, and echoes
the compiler's lines so build logs stay readable.
- the version probe compiles a minimal script from standard input into a
throwaway OutputDir, so it never touches the caller's -OutDir.
- only .e32 exists for the engine; drop the unused .e64 handling.
- the uninstaller signature test also checks the release publisher, and
the test-builds doc warns that Smart App Control cannot be turned back
on without resetting Windows.
* windows: correct the setup engine comments
156 lines
6.7 KiB
YAML
156 lines
6.7 KiB
YAML
name: Windows installers
|
|
|
|
# Builds hex-setup-<version>-windows-<x64|arm64>.exe (packaging/windows/hex.iss)
|
|
# around the Windows executables (hex.exe and hex.com) in the artifacts that match `pattern`, then
|
|
# installs, reinstalls, installs over another version, and uninstalls each
|
|
# silently on native x64 and ARM64 runners. Release passes the signed
|
|
# executables and signs the installers afterwards; Test builds passes the
|
|
# unsigned ones. Repository code runs here, so there is no environment, no
|
|
# secret, and no id-token; artifacts are checked against the digests their
|
|
# jobs reported (.github/release/verify-artifacts.sh).
|
|
#
|
|
# With `signed-engine`, this is the second pass: the compiler embeds the signed
|
|
# setup engine in the artifact `engine-artifact-name` (windows-setup-engine.yml
|
|
# built it, the release environment signed it), so the installed uninstaller
|
|
# and the copy Setup extracts to %TEMP% carry the release signature, and the
|
|
# tests assert it (scripts/test-windows-installer.ps1 -SignedEngine).
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
sha:
|
|
required: true
|
|
type: string
|
|
version:
|
|
required: true
|
|
type: string
|
|
pattern:
|
|
description: Artifact name pattern of the executables
|
|
required: true
|
|
type: string
|
|
digests:
|
|
description: Space-separated name=digest pairs for those artifacts
|
|
required: true
|
|
type: string
|
|
artifact-name:
|
|
description: The installers' artifact
|
|
required: true
|
|
type: string
|
|
signed-engine:
|
|
description: Embed the signed setup engine in the artifact engine-artifact-name
|
|
type: boolean
|
|
default: false
|
|
engine-artifact-name:
|
|
description: The signed setup engine's artifact (with signed-engine)
|
|
type: string
|
|
default: ""
|
|
engine-digest:
|
|
description: Its digest, reported by the job that signed it (with signed-engine)
|
|
type: string
|
|
default: ""
|
|
retention-days:
|
|
type: number
|
|
default: 0
|
|
outputs:
|
|
digest:
|
|
value: ${{ jobs.package.outputs.digest }}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
package:
|
|
name: Build the installers
|
|
runs-on: windows-latest
|
|
timeout-minutes: 30
|
|
env:
|
|
HEX_VERSION: ${{ inputs.version }}
|
|
SIGNED_ENGINE: ${{ inputs.signed-engine }}
|
|
ENGINE_ARTIFACT: ${{ inputs.engine-artifact-name }}
|
|
outputs:
|
|
digest: ${{ steps.upload.outputs.digest }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ inputs.sha }}
|
|
persist-credentials: false
|
|
- uses: ./.github/release/download
|
|
with:
|
|
# One download checks everything the job uses, including the signed
|
|
# setup engine when there is one.
|
|
pattern: ${{ inputs.signed-engine && format('{{{0},{1}}}', inputs.pattern, inputs.engine-artifact-name) || inputs.pattern }}
|
|
digests: ${{ inputs.digests }}${{ inputs.signed-engine && format(' {0}={1}', inputs.engine-artifact-name, inputs.engine-digest) || '' }}
|
|
- name: Build the installers around the executables
|
|
shell: pwsh
|
|
run: |
|
|
$out = New-Item -ItemType Directory -Force "$env:RUNNER_TEMP/installers"
|
|
$engine = $null
|
|
if ($env:SIGNED_ENGINE -eq 'true') {
|
|
$engine = Join-Path "$env:RUNNER_TEMP/in" $env:ENGINE_ARTIFACT
|
|
$found = @(Get-ChildItem -LiteralPath $engine -File | Where-Object { $_.Name -like 'uninst-*.e32' })
|
|
if ($found.Count -eq 0) { throw "No signed uninst-*.e32 in $engine." }
|
|
}
|
|
foreach ($arch in 'x86_64', 'aarch64') {
|
|
$label = if ($arch -eq 'x86_64') { 'x64' } else { 'arm64' }
|
|
$exe = @(Get-ChildItem "$env:RUNNER_TEMP/in" -Recurse -Filter "hex-$env:HEX_VERSION-windows-$label.exe")
|
|
if ($exe.Count -ne 1) { throw "Expected one hex-$env:HEX_VERSION-windows-$label.exe, found $($exe.Count)." }
|
|
$console = @(Get-ChildItem "$env:RUNNER_TEMP/in" -Recurse -Filter "hex-$env:HEX_VERSION-windows-$label.com")
|
|
if ($console.Count -ne 1) { throw "Expected one hex-$env:HEX_VERSION-windows-$label.com, found $($console.Count)." }
|
|
$arguments = @{
|
|
Executable = $exe[0].FullName
|
|
Console = $console[0].FullName
|
|
Version = $env:HEX_VERSION
|
|
Arch = $arch
|
|
OutDir = $out
|
|
}
|
|
if ($engine) { $arguments.SignedEngineDir = $engine }
|
|
scripts/build-windows-installer.ps1 @arguments
|
|
}
|
|
Get-ChildItem $out | Where-Object { $_.Name -notlike 'hex-setup-*.exe' } | Remove-Item -Recurse -Force
|
|
- id: upload
|
|
uses: ./.github/release/upload
|
|
with:
|
|
name: ${{ inputs.artifact-name }}
|
|
path: ${{ runner.temp }}/installers
|
|
retention-days: ${{ inputs.retention-days }}
|
|
|
|
test:
|
|
name: Test the ${{ matrix.label }} installer
|
|
needs: package
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 30
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- label: x64
|
|
runner: windows-latest
|
|
- label: arm64
|
|
runner: windows-11-arm
|
|
env:
|
|
HEX_VERSION: ${{ inputs.version }}
|
|
SIGNED_ENGINE: ${{ inputs.signed-engine }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ inputs.sha }}
|
|
persist-credentials: false
|
|
- uses: ./.github/release/download
|
|
with:
|
|
pattern: "{${{ inputs.pattern }},${{ inputs.artifact-name }}}"
|
|
digests: ${{ inputs.digests }} ${{ inputs.artifact-name }}=${{ needs.package.outputs.digest }}
|
|
- name: Install, reinstall, install over another version, and uninstall silently
|
|
shell: pwsh
|
|
run: |
|
|
$exe = @(Get-ChildItem "$env:RUNNER_TEMP/in" -Recurse -Filter "hex-$env:HEX_VERSION-windows-${{ matrix.label }}.exe")[0].FullName
|
|
$console = @(Get-ChildItem "$env:RUNNER_TEMP/in" -Recurse -Filter "hex-$env:HEX_VERSION-windows-${{ matrix.label }}.com")[0].FullName
|
|
$setup = @(Get-ChildItem "$env:RUNNER_TEMP/in" -Recurse -Filter "hex-setup-$env:HEX_VERSION-windows-${{ matrix.label }}.exe")[0].FullName
|
|
$arguments = @{ Installer = $setup; Executable = $exe; Console = $console; Version = $env:HEX_VERSION }
|
|
if ($env:SIGNED_ENGINE -eq 'true') { $arguments.SignedEngine = $true }
|
|
scripts/test-windows-installer.ps1 @arguments
|
|
- name: Upload installer logs
|
|
if: failure()
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
|
with:
|
|
name: windows-installer-logs-${{ matrix.label }}
|
|
path: ${{ runner.temp }}/hex-installer-logs
|
|
if-no-files-found: ignore
|