From f4e911c14a07a3b9e0a238a0d08154e39fcdef46 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Mon, 13 Jul 2026 21:46:48 +0800 Subject: [PATCH] build: add Windows desktop test bundle --- .gitignore | 1 + README.md | 24 ++++++++++++ scripts/build-windows.sh | 72 +++++++++++++++++++++++++++++++++++ scripts/test-build-windows.sh | 19 +++++++++ 4 files changed, 116 insertions(+) create mode 100755 scripts/build-windows.sh create mode 100755 scripts/test-build-windows.sh diff --git a/.gitignore b/.gitignore index 54a874b..999a052 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ frontend/node_modules/ frontend/dist/ build/bin/verstak-desktop +build/windows-amd64/ smoke-platform plugins/ vendor/ diff --git a/README.md b/README.md index fec6f04..f473255 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,30 @@ diagnostic logs: ./build/bin/verstak-desktop --debug ``` +## Windows test bundle from Linux + +The current Windows path is intended for manual testing, not publication. On a +Linux host install MinGW, then run: + +```bash +sudo apt install gcc-mingw-w64-x86-64 +./scripts/build-windows.sh +``` + +The script builds Windows amd64 plugin packages from the sibling +`verstak-official-plugins` checkout, cross-compiles the Wails host, and writes +a folder ready to copy to a Windows machine: + +```text +build/windows-amd64/ +├── verstak-desktop.exe +└── plugins/ +``` + +Copy the whole directory to Windows and run `verstak-desktop.exe`. Windows +requires the Microsoft WebView2 Runtime; Windows 11 normally includes it. +No Windows GitHub Release is created by this command. + ## First local vault 1. Launch the desktop application and choose or create a writable vault folder. diff --git a/scripts/build-windows.sh b/scripts/build-windows.sh new file mode 100755 index 0000000..3ba4357 --- /dev/null +++ b/scripts/build-windows.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +OFFICIAL_PLUGINS="${VERSTAK_OFFICIAL_PLUGINS_DIR:-$ROOT/../verstak-official-plugins}" +WINDOWS_PLUGIN_DIST="${VERSTAK_WINDOWS_PLUGIN_DIST:-$OFFICIAL_PLUGINS/dist-windows}" +WINDOWS_OUTPUT="${VERSTAK_WINDOWS_OUTPUT_DIR:-$ROOT/build/windows-amd64}" +WINDOWS_CC="${VERSTAK_WINDOWS_CC:-x86_64-w64-mingw32-gcc}" + +if ! command -v "$WINDOWS_CC" >/dev/null; then + echo "Windows cross-compiler not found: $WINDOWS_CC" >&2 + echo "Install x86_64-w64-mingw32-gcc (for example: sudo apt install gcc-mingw-w64-x86-64)." >&2 + exit 1 +fi +if [[ ! -d "$OFFICIAL_PLUGINS" ]]; then + echo "official plugins repository not found: $OFFICIAL_PLUGINS" >&2 + exit 1 +fi + +WAILS="${WAILS_BIN:-}" +if [[ -z "$WAILS" ]]; then + if command -v wails >/dev/null; then + WAILS="wails" + elif [[ -n "$(go env GOBIN 2>/dev/null)" && -x "$(go env GOBIN)/wails" ]]; then + WAILS="$(go env GOBIN)/wails" + elif [[ -x "$(go env GOPATH)/bin/wails" ]]; then + WAILS="$(go env GOPATH)/bin/wails" + fi +fi +if [[ -z "$WAILS" ]]; then + echo "Wails CLI is required. Install it with: go install github.com/wailsapp/wails/v2/cmd/wails@v2.12.0" >&2 + exit 1 +fi + +cd "$ROOT" +echo "=== verstak desktop Windows amd64 build ===" + +if [[ ! -d "$ROOT/frontend/node_modules" ]]; then + if [[ -f "$ROOT/frontend/package-lock.json" ]]; then + (cd "$ROOT/frontend" && npm ci --no-audit --no-fund) + else + (cd "$ROOT/frontend" && npm install --no-audit --no-fund) + fi +fi +(cd "$ROOT/frontend" && npm run build) + +go mod download +go test -count=1 ./... + +"$OFFICIAL_PLUGINS/scripts/build-windows.sh" +if [[ ! -d "$WINDOWS_PLUGIN_DIST" ]]; then + echo "Windows plugin packages were not produced: $WINDOWS_PLUGIN_DIST" >&2 + exit 1 +fi + +# Wails generates Windows resources and invokes the supplied MinGW compiler. +# -clean resets build/bin, so copy the finished executable only afterwards. +"$WAILS" build -clean -platform windows/amd64 -compiler "$WINDOWS_CC" -o verstak-desktop.exe + +WINDOWS_BINARY="$ROOT/build/bin/verstak-desktop.exe" +if [[ ! -f "$WINDOWS_BINARY" ]]; then + echo "Windows executable was not produced: $WINDOWS_BINARY" >&2 + exit 1 +fi + +rm -rf "$WINDOWS_OUTPUT" +mkdir -p "$WINDOWS_OUTPUT/plugins" +cp "$WINDOWS_BINARY" "$WINDOWS_OUTPUT/verstak-desktop.exe" +cp -R "$WINDOWS_PLUGIN_DIST/." "$WINDOWS_OUTPUT/plugins/" + +echo "Windows test bundle: $WINDOWS_OUTPUT" +echo "Copy this directory to Windows and run verstak-desktop.exe." diff --git a/scripts/test-build-windows.sh b/scripts/test-build-windows.sh new file mode 100755 index 0000000..d712880 --- /dev/null +++ b/scripts/test-build-windows.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +BUILDER="$ROOT/scripts/build-windows.sh" + +if [[ ! -x "$BUILDER" ]]; then + echo "Windows desktop builder is missing or not executable: $BUILDER" >&2 + exit 1 +fi + +bash -n "$BUILDER" +grep -Fq -- '-platform windows/amd64' "$BUILDER" +grep -Fq -- '-compiler "$WINDOWS_CC"' "$BUILDER" +grep -Fq 'dist-windows' "$BUILDER" +grep -Fq 'verstak-desktop.exe' "$BUILDER" +grep -Fq 'x86_64-w64-mingw32-gcc' "$BUILDER" + +echo "Windows desktop build script contract passed"