mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 18:25:34 +01:00
Merge pull request #10157 from dotCooCoo/fix/unsigned-windows-notice
Packaging: unsigned Windows builds the caller asked for print a notice
This commit is contained in:
2 files changed
+36
-2
No files matched your search
@@ -73,6 +73,29 @@ try {
|
||||
Clear-SigningFixtures
|
||||
Write-Output 'PASS: supported-configuration-presence-without-signing'
|
||||
|
||||
# The unsigned message is captured here, so it does not become an annotation of this job.
|
||||
$optInFile = Join-Path $root 'opt-in-sentinel.exe'
|
||||
[IO.File]::WriteAllText($optInFile, 'generated sentinel, not a real executable')
|
||||
$savedActions = $env:GITHUB_ACTIONS
|
||||
try {
|
||||
$env:GITHUB_ACTIONS = 'true'
|
||||
$env:CRAFT_ALLOW_UNSIGNED = $null
|
||||
$default = (& $sign $optInFile) -join "`n"
|
||||
Assert-Policy ($default.Contains('::warning::Windows signing secrets not set')) "unsigned output without the opt-in must warn; got: $default"
|
||||
$env:CRAFT_ALLOW_UNSIGNED = '1'
|
||||
$optedIn = (& $sign $optInFile) -join "`n"
|
||||
Assert-Policy ($optedIn.Contains('::notice::Windows signing secrets not set')) "opted-in unsigned output must be a notice; got: $optedIn"
|
||||
Assert-Policy (-not $optedIn.Contains('::warning::')) "opted-in unsigned output must not warn; got: $optedIn"
|
||||
foreach ($value in @('true', '0', 'yes')) {
|
||||
$env:CRAFT_ALLOW_UNSIGNED = $value
|
||||
Invoke-Refusal { & $sign $optInFile } 'CRAFT_ALLOW_UNSIGNED must be 1 or unset'
|
||||
}
|
||||
} finally {
|
||||
$env:CRAFT_ALLOW_UNSIGNED = $null
|
||||
$env:GITHUB_ACTIONS = $savedActions
|
||||
}
|
||||
Write-Output 'PASS: opted-in-unsigned-output-is-a-notice'
|
||||
|
||||
# Load the policy function without signing. These objects are not crypto evidence.
|
||||
. $sign -CheckOnly
|
||||
foreach ($value in @($null, [pscustomobject]@{Status='NotSigned';SignerCertificate='fixture'}, [pscustomobject]@{Status='HashMismatch';SignerCertificate='fixture'}, [pscustomobject]@{Status='Valid';SignerCertificate=$null})) {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
AZURE_SIGNING_ENDPOINT (e.g. https://eus.codesigning.azure.net),
|
||||
AZURE_SIGNING_ACCOUNT, AZURE_CERT_PROFILE
|
||||
With neither, it prints a warning and leaves the files unsigned (exit code 0), so test builds
|
||||
still produce installers. Nightly callers require signing with -Required and can check the
|
||||
still produce installers. A caller that builds unsigned on purpose sets CRAFT_ALLOW_UNSIGNED=1,
|
||||
and the message is then a notice instead of a warning. Nightly callers require signing with -Required and can check the
|
||||
signing configuration with -Required -CheckOnly. Compilation uses the separate
|
||||
-CheckBuildEnvironment mode, which refuses any signing material without importing a key.
|
||||
|
||||
@@ -38,6 +39,10 @@ function Write-Warn([string] $Message) {
|
||||
if ($env:GITHUB_ACTIONS) { Write-Output "::warning::$Message" } else { Write-Warning $Message }
|
||||
}
|
||||
|
||||
function Write-Note([string] $Message) {
|
||||
if ($env:GITHUB_ACTIONS) { Write-Output "::notice::$Message" } else { Write-Output $Message }
|
||||
}
|
||||
|
||||
function Find-SignTool {
|
||||
if ($env:SIGNTOOL) { return $env:SIGNTOOL }
|
||||
$onPath = Get-Command signtool.exe -ErrorAction SilentlyContinue
|
||||
@@ -64,6 +69,11 @@ if ($CheckBuildEnvironment) {
|
||||
}
|
||||
return
|
||||
}
|
||||
$allowUnsigned = switch -CaseSensitive ([string]$env:CRAFT_ALLOW_UNSIGNED) {
|
||||
'' { $false }
|
||||
'1' { $true }
|
||||
default { throw "CRAFT_ALLOW_UNSIGNED must be 1 or unset, got '$env:CRAFT_ALLOW_UNSIGNED'" }
|
||||
}
|
||||
$haveCert = [bool]$env:WINDOWS_CERTIFICATE
|
||||
$haveAzure = -not ($azureVars | Where-Object { -not [Environment]::GetEnvironmentVariable($_) })
|
||||
|
||||
@@ -78,7 +88,8 @@ if (-not $Files) { throw 'At least one file is required for signing' }
|
||||
$Files = $Files | ForEach-Object { (Resolve-Path $_).Path }
|
||||
|
||||
if (-not $haveCert -and -not $haveAzure) {
|
||||
Write-Warn "Windows signing secrets not set (WINDOWS_CERTIFICATE or AZURE_*): leaving unsigned: $($Files -join ', ')"
|
||||
$message = "Windows signing secrets not set (WINDOWS_CERTIFICATE or AZURE_*): leaving unsigned: $($Files -join ', ')"
|
||||
if ($allowUnsigned) { Write-Note $message } else { Write-Warn $message }
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user