Skip to content

Commit 2c5ae37

Browse files
authored
Merge pull request #1 from nsis-dev/windows-support
feat: add windows support
2 parents b595597 + 2eca0c6 commit 2c5ae37

3 files changed

Lines changed: 106 additions & 28 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: Run tests
22

33
on:
44
push:
5+
paths-ignore: ["**.md", LICENSE]
56
pull_request:
7+
paths-ignore: ["**.md", LICENSE]
68
workflow_dispatch:
79

810
jobs:
@@ -12,10 +14,11 @@ jobs:
1214
strategy:
1315
fail-fast: false
1416
matrix:
15-
os: [ubuntu-latest, macos-latest]
17+
os: [ubuntu-latest, macos-latest, windows-latest]
1618
variant: [default, large-strings, advanced-logging]
1719
steps:
18-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
20+
- name: Checkout
21+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
1922

2023
- name: Setup NSIS
2124
id: nsis
@@ -37,10 +40,8 @@ jobs:
3740
[ "$OUT_NSISDIR" = "$NSISDIR" ]
3841
[ -f "$NSISDIR/Include/MUI2.nsh" ]
3942
40-
# makensis must come from PATH, i.e. the action put $PREFIX/bin there
41-
makensis -VERSION
43+
# Unqualified: proves the action put the bin dir on PATH
4244
info=$(makensis -HDRINFO)
43-
echo "$info"
4445
4546
strlen=8192
4647
[ "$LARGE" = "true" ] || strlen=1024
@@ -66,13 +67,34 @@ jobs:
6667
makensis test.nsi
6768
[ -f test.exe ]
6869
70+
windows-combo-rejected:
71+
runs-on: windows-latest
72+
steps:
73+
- name: Checkout
74+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
75+
- name: Setup NSIS with both special builds
76+
id: nsis
77+
continue-on-error: true
78+
uses: ./
79+
with:
80+
large-strings: true
81+
advanced-logging: true
82+
83+
- name: Check the step failed
84+
shell: bash
85+
run: '[ "${{ steps.nsis.outcome }}" = failure ]'
86+
6987
pinned-version:
7088
runs-on: ubuntu-latest
7189
steps:
72-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
73-
- id: nsis
90+
- name: Checkout
91+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
92+
- name: Setup NSIS
93+
id: nsis
7494
uses: ./
7595
with:
7696
version: "3.10"
77-
- shell: bash
97+
98+
- name: Check the pinned version was used
99+
shell: bash
78100
run: '[ "${{ steps.nsis.outputs.version }}" = "3.10" ] && makensis -VERSION | grep -q 3.10'

‎README.md‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
Set up [NSIS](https://nsis.sourceforge.io/) in your GitHub workflow.
88

9-
> [!WARNING]
10-
> This action currently only supports Linux and macOS runners.
11-
129
## Usage
1310

1411
```yaml
@@ -31,8 +28,13 @@ With build options:
3128
| Name | Default | Description |
3229
| ------------------ | -------- | ------------------------------------------------------------- |
3330
| `version` | `latest` | NSIS version, e.g. `3.12`. `latest` resolves via SourceForge. |
34-
| `large-strings` | `false` | Build with `NSIS_MAX_STRLEN=8192`. |
35-
| `advanced-logging` | `false` | Build with `NSIS_CONFIG_LOG=yes`. |
31+
| `large-strings` | `false` | `NSIS_MAX_STRLEN=8192`. |
32+
| `advanced-logging` | `false` | `NSIS_CONFIG_LOG=yes`. |
33+
34+
> [!NOTE]
35+
> On Windows, `large-strings` and `advanced-logging` cannot be combined: the
36+
> action uses upstream's prebuilt special builds and there is no build that
37+
> ships both. Enabling both fails the step.
3638

3739
## Outputs
3840

@@ -41,8 +43,9 @@ With build options:
4143
| `version` | Resolved NSIS version. |
4244
| `nsisdir` | NSIS installation directory (also exported as `NSISDIR`). |
4345

44-
Builds are cached per OS, version and option combination, so only the first run
45-
pays the compile cost.
46+
On Linux and macOS, NSIS is built from source; on Windows the action installs
47+
upstream's prebuilt binaries. Either way the result is cached per OS, version
48+
and option combination, so only the first run pays the setup cost.
4649

4750
## License
4851

‎action.yml‎

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name: Setup NSIS
2-
description: Build NSIS from source on Linux and macOS and expose it via NSISDIR
2+
description: Set up NSIS on Linux, macOS and Windows and expose it via NSISDIR
33

44
inputs:
55
version:
66
description: NSIS version, e.g. 3.12, or "latest"
77
default: latest
88
large-strings:
9-
description: Build with NSIS_MAX_STRLEN=8192
9+
description: NSIS_MAX_STRLEN=8192
1010
default: "false"
1111
advanced-logging:
12-
description: Build with NSIS_CONFIG_LOG=yes
12+
description: NSIS_CONFIG_LOG=yes
1313
default: "false"
1414

1515
outputs:
@@ -18,7 +18,7 @@ outputs:
1818
value: ${{ steps.vars.outputs.version }}
1919
nsisdir:
2020
description: NSIS installation directory
21-
value: ${{ steps.vars.outputs.prefix }}/share/nsis
21+
value: ${{ steps.vars.outputs.nsisdir }}
2222

2323
runs:
2424
using: composite
@@ -32,16 +32,38 @@ runs:
3232
LOG: ${{ inputs.advanced-logging }}
3333
run: |
3434
set -euo pipefail
35+
3536
if [ "$VERSION" = latest ]; then
3637
# SourceForge has no "latest file" URL; its release JSON names the current one
3738
VERSION=$(curl -fsSL "https://sourceforge.net/projects/nsis/best_release.json" \
3839
| grep -o 'nsis-[0-9.]*-src\.tar\.bz2' | head -1 | sed 's/^nsis-//;s/-src.*//')
3940
[ -n "$VERSION" ] || { echo "could not resolve latest NSIS version"; exit 1; }
4041
echo "resolved latest NSIS version: $VERSION"
4142
fi
43+
44+
if [ "${{ runner.os }}" = Windows ]; then
45+
# Windows uses upstream's prebuilt binaries, and there is no build that
46+
# combines both special builds
47+
if [ "$LARGE" = "true" ] && [ "$LOG" = "true" ]; then
48+
echo "large-strings and advanced-logging cannot be combined on Windows" >&2
49+
exit 1
50+
fi
51+
52+
# Forward slashes: usable from bash and from PATH alike
53+
prefix=$(cygpath -m "$HOME/nsis")
54+
nsisdir=$prefix
55+
bindir=$prefix
56+
else
57+
prefix=$HOME/nsis
58+
nsisdir=$prefix/share/nsis
59+
bindir=$prefix/bin
60+
fi
61+
4262
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
43-
echo "prefix=$HOME/nsis" >> "$GITHUB_OUTPUT"
44-
echo "key=nsis-${{ runner.os }}-$VERSION-ls$LARGE-al$LOG" >> "$GITHUB_OUTPUT"
63+
echo "prefix=$prefix" >> "$GITHUB_OUTPUT"
64+
echo "nsisdir=$nsisdir" >> "$GITHUB_OUTPUT"
65+
echo "bindir=$bindir" >> "$GITHUB_OUTPUT"
66+
echo "key=nsis-${{ runner.os }}-$VERSION-largeStrings=$LARGE-advancedLogging=$LOG" >> "$GITHUB_OUTPUT"
4567
4668
- name: Restore cached NSIS build
4769
id: cache
@@ -50,6 +72,36 @@ runs:
5072
path: ~/nsis
5173
key: ${{ steps.vars.outputs.key }}
5274

75+
# Upstream ships prebuilt Windows binaries, including for both special builds,
76+
# so there is nothing to compile here
77+
- name: Install NSIS (Windows)
78+
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
79+
shell: bash
80+
working-directory: ${{ runner.temp }}
81+
env:
82+
VERSION: ${{ steps.vars.outputs.version }}
83+
LARGE: ${{ inputs.large-strings }}
84+
LOG: ${{ inputs.advanced-logging }}
85+
PREFIX: ${{ steps.vars.outputs.prefix }}
86+
run: |
87+
set -euo pipefail
88+
base="https://downloads.sourceforge.net/project/nsis/NSIS%20${VERSION%%.*}/$VERSION"
89+
curl -fsSLO "$base/nsis-$VERSION.zip"
90+
7z x -y -bso0 "nsis-$VERSION.zip"
91+
92+
mkdir -p "$PREFIX"
93+
cp -R "nsis-$VERSION/." "$PREFIX/"
94+
95+
# Special builds are overlays: makensis.exe plus matching stubs, no top-level dir
96+
variant=""
97+
[ "$LARGE" = "true" ] && variant="strlen_8192"
98+
[ "$LOG" = "true" ] && variant="log"
99+
100+
if [ -n "$variant" ]; then
101+
curl -fsSLO "$base/nsis-$VERSION-$variant.zip"
102+
7z x -y -bso0 -o"$PREFIX" "nsis-$VERSION-$variant.zip"
103+
fi
104+
53105
- name: Install build dependencies (Linux)
54106
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
55107
shell: bash
@@ -67,7 +119,7 @@ runs:
67119
brew install scons mingw-w64
68120
69121
- name: Download and build NSIS
70-
if: steps.cache.outputs.cache-hit != 'true'
122+
if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
71123
shell: bash
72124
working-directory: ${{ runner.temp }}
73125
env:
@@ -98,6 +150,7 @@ runs:
98150
STRIP=0
99151
VERSION="$VERSION"
100152
)
153+
101154
[ "$LARGE" = "true" ] && args+=(NSIS_MAX_STRLEN=8192)
102155
[ "$LOG" = "true" ] && args+=(NSIS_CONFIG_LOG=yes)
103156
@@ -108,12 +161,12 @@ runs:
108161
- name: Export NSISDIR and verify
109162
shell: bash
110163
env:
111-
PREFIX: ${{ steps.vars.outputs.prefix }}
164+
NSISDIR: ${{ steps.vars.outputs.nsisdir }}
165+
BINDIR: ${{ steps.vars.outputs.bindir }}
112166
run: |
113167
set -euo pipefail
114-
echo "NSISDIR=$PREFIX/share/nsis" >> "$GITHUB_ENV"
115-
echo "$PREFIX/bin" >> "$GITHUB_PATH"
116-
export NSISDIR="$PREFIX/share/nsis"
117-
echo "makensis v$("$PREFIX/bin/makensis" -VERSION)"
168+
echo "NSISDIR=$NSISDIR" >> "$GITHUB_ENV"
169+
echo "$BINDIR" >> "$GITHUB_PATH"
170+
echo "makensis $("$BINDIR/makensis" -VERSION)"
118171
echo
119-
"$PREFIX/bin/makensis" -HDRINFO
172+
"$BINDIR/makensis" -HDRINFO

0 commit comments

Comments
 (0)