11name : 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
44inputs :
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
1515outputs :
@@ -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
2323runs :
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
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
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 :
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