Skip to content

Commit ea2c36f

Browse files
author
Shimi Dudkin
committed
fix(windows): build and publish NSIS installer
1 parent 7296e96 commit ea2c36f

3 files changed

Lines changed: 84 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,44 @@ jobs:
202202
name: screenmcp-android
203203
path: ${{ steps.apk.outputs.path }}
204204

205+
build-windows-installer:
206+
runs-on: ubuntu-latest
207+
208+
steps:
209+
- uses: actions/checkout@v4
210+
211+
- name: Install build dependencies
212+
run: |
213+
sudo apt-get update
214+
sudo apt-get install -y nsis mingw-w64
215+
216+
- name: Install Rust toolchain (Windows GNU target)
217+
uses: dtolnay/rust-toolchain@stable
218+
with:
219+
targets: x86_64-pc-windows-gnu
220+
221+
- name: Build Windows installer (.exe)
222+
working-directory: windows
223+
run: ./build-installer.sh "${GITHUB_REF_NAME#v}"
224+
225+
- name: Determine installer name
226+
id: installer
227+
shell: bash
228+
run: |
229+
version="${GITHUB_REF_NAME#v}"
230+
file="screenmcp-setup-${version}-x86_64.exe"
231+
cp "windows/target/installer/${file}" "${file}"
232+
echo "path=${file}" >> "$GITHUB_OUTPUT"
233+
echo "name=${file}" >> "$GITHUB_OUTPUT"
234+
235+
- name: Upload artifact
236+
uses: actions/upload-artifact@v4
237+
with:
238+
name: screenmcp-windows-installer
239+
path: ${{ steps.installer.outputs.path }}
240+
205241
release:
206-
needs: [build-desktop, build-android]
242+
needs: [build-desktop, build-android, build-windows-installer]
207243
runs-on: ubuntu-latest
208244
steps:
209245
- uses: actions/checkout@v4
@@ -216,7 +252,7 @@ jobs:
216252
- name: Collect release assets
217253
run: |
218254
mkdir -p release
219-
find artifacts -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name '*.apk' -o -name '*.dmg' \) -exec mv {} release/ \;
255+
find artifacts -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name '*.apk' -o -name '*.dmg' -o -name 'screenmcp-setup-*-x86_64.exe' \) -exec mv {} release/ \;
220256
ls -lh release/
221257
222258
- name: Generate checksums
@@ -241,6 +277,7 @@ jobs:
241277
| **macOS (Apple Silicon)** | `screenmcp-mac-aarch64-apple-darwin-*.dmg` | M1/M2/M3/M4 Macs |
242278
| **macOS (Intel)** | `screenmcp-mac-x86_64-apple-darwin-*.dmg` | Older Intel Macs |
243279
| **Windows** | `screenmcp-windows-*.zip` | x86_64 |
280+
| **Windows Installer** | `screenmcp-setup-*-x86_64.exe` | NSIS setup wizard |
244281
| **Linux** | `screenmcp-linux-*.tar.gz` | x86_64 |
245282
| **Android** | `screenmcp-android-*.apk` | ARM/x86 |
246283

windows/build-installer.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ if ! "$RUSTUP" target list --installed | grep -q "x86_64-pc-windows-gnu"; then
3636
"$RUSTUP" target add x86_64-pc-windows-gnu
3737
fi
3838

39+
VENDOR_DIR="$SCRIPT_DIR/vendor"
40+
CARGO_HOME_TMP=""
41+
if [ -d "$VENDOR_DIR" ]; then
42+
echo " Using vendored dependencies from $VENDOR_DIR"
43+
CARGO_HOME_TMP="$(mktemp -d)"
44+
mkdir -p "$CARGO_HOME_TMP"
45+
trap 'rm -rf "$CARGO_HOME_TMP"' EXIT
46+
cat >"$CARGO_HOME_TMP/config.toml" <<EOF
47+
[source.crates-io]
48+
replace-with = "vendored-sources"
49+
50+
[source.vendored-sources]
51+
directory = "$VENDOR_DIR"
52+
EOF
53+
export CARGO_HOME="$CARGO_HOME_TMP"
54+
export CARGO_NET_OFFLINE=true
55+
fi
56+
3957
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc \
4058
cargo build --release --target x86_64-pc-windows-gnu
4159

windows/vendor-deps.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
# Vendor Rust dependencies for offline builds.
3+
# Usage: ./vendor-deps.sh
4+
set -euo pipefail
5+
6+
# Source Rust environment if not already in PATH
7+
if ! command -v cargo &>/dev/null; then
8+
if [ -f "$HOME/.cargo/env" ]; then
9+
source "$HOME/.cargo/env"
10+
elif [ -f "/home/user/.cargo/env" ]; then
11+
source "/home/user/.cargo/env"
12+
else
13+
echo "ERROR: cargo not found. Install Rust: https://rustup.rs"
14+
exit 1
15+
fi
16+
fi
17+
18+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19+
VENDOR_DIR="$SCRIPT_DIR/vendor"
20+
21+
mkdir -p "$VENDOR_DIR"
22+
23+
# This requires network access the first time. After that, build-installer.sh can run offline.
24+
# We keep output quiet and deterministic by using the lockfile.
25+
cargo vendor "$VENDOR_DIR" >/dev/null
26+
27+
echo "Vendored dependencies to: $VENDOR_DIR"

0 commit comments

Comments
 (0)