Skip to content

Commit 63e9507

Browse files
authored
Add makensis-action step to sign-pkg-windows (#21)
1 parent 220c88d commit 63e9507

File tree

1 file changed

+56
-10
lines changed

1 file changed

+56
-10
lines changed

sign-pkg-windows/action.yaml

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,50 @@ inputs:
1818
tenant_id:
1919
description: "Azure signer app tenantId"
2020
required: true
21+
nsis_version:
22+
description: "NSIS version to install if not already present"
23+
default: '3.10'
24+
required: true
2125

2226
runs:
2327
using: composite
2428
steps:
29+
- name: Setup NSIS
30+
# Install NSIS if not already installed on the runner
31+
# See https://nsis.sourceforge.io/Download
32+
shell: pwsh
33+
env:
34+
NSIS_VERSION: ${{ inputs.nsis_version }}
35+
run: |
36+
$ErrorActionPreference = 'Stop'
37+
$version = $env:NSIS_VERSION
38+
$existing = (Get-Command makensis.exe -ErrorAction SilentlyContinue)
39+
if ($existing) {
40+
Write-Host "Found existing makensis at $($existing.Source) - skipping download"
41+
& $existing.Source -VERSION
42+
return
43+
}
44+
$zipName = "nsis-$version.zip"
45+
$url = "https://downloads.sourceforge.net/project/nsis/NSIS%203/$version/$zipName"
46+
$zipPath = Join-Path $env:RUNNER_TEMP $zipName
47+
Write-Host "Downloading NSIS $version from $url"
48+
try {
49+
$curlProcess = Start-Process -FilePath "curl.exe" -ArgumentList "-L", "-o", "`"$zipPath`"", "`"$url`"" -NoNewWindow -Wait -PassThru
50+
if ($curlProcess.ExitCode -ne 0) { throw "curl exited with code $($curlProcess.ExitCode)" }
51+
} catch {
52+
Write-Error "Download failed with curl: $($_.Exception.Message)"
53+
throw
54+
}
55+
$dest = Join-Path $env:RUNNER_TEMP "nsis-unpacked"
56+
if (Test-Path $dest) { Remove-Item -Recurse -Force $dest }
57+
Expand-Archive -Path $zipPath -DestinationPath $dest
58+
$makensis = Get-ChildItem -Path $dest -Recurse -Filter makensis.exe | Select-Object -First 1
59+
if (-not $makensis) { throw 'makensis.exe not found in extracted archive' }
60+
$binDir = Split-Path $makensis.FullName
61+
Add-Content -Path $env:GITHUB_PATH -Value $binDir
62+
Write-Host "NSIS added to PATH: $binDir"
63+
& $makensis.FullName -VERSION
64+
2565
- name: Fetch Windows app
2666
uses: actions/download-artifact@v4
2767
with:
@@ -56,23 +96,29 @@ runs:
5696
id: nsis
5797
shell: python
5898
run: |
59-
# Logic derived from viewer_manifest.py - still needed though?
6099
# Use Python because bash refuses to expand "${programfiles(x86)}" --
61100
# even though that's really the name of the Windows environment
62101
# variable.
63102
import os
64103
import shlex
65104
from shutil import which
66105
import subprocess
67-
nsis_path = which(
68-
"makensis",
69-
path=os.pathsep.join(
70-
os.path.join(program_files, subpath)
71-
for program_files in
72-
(os.getenv(var) for var in ('programfiles', 'programfiles(x86)'))
73-
for subpath in ('NSIS', r'NSIS\Unicode')
74-
if program_files))
75-
assert nsis_path
106+
107+
# First try to find makensis in PATH (for installed NSIS)
108+
nsis_path = which("makensis")
109+
110+
# If not found in PATH, try the old Program Files locations (fallback)
111+
if not nsis_path:
112+
nsis_path = which(
113+
"makensis",
114+
path=os.pathsep.join(
115+
os.path.join(program_files, subpath)
116+
for program_files in
117+
(os.getenv(var) for var in ('programfiles', 'programfiles(x86)'))
118+
for subpath in ('NSIS', r'NSIS\Unicode')
119+
if program_files))
120+
121+
assert nsis_path, "makensis not found in PATH or standard NSIS installation directories"
76122
77123
# This .nsi file was prepared by viewer_manifest.py (by substituting
78124
# values into a template .nsi file) and bundled into the top level of

0 commit comments

Comments
 (0)