Commitf3922fd9Recorded14 Jul 2026Repositorysigil-site

publish.sh: build web REPL by default on production publish

Message

Make the WASM REPL part of a production publish by default (add --skip-repl as the explicit opt-out) so a live deploy can never silently ship a stale REPL wasm, which previously left usesigil.org's REPL at an old version while the rest of the site moved ahead.

Changed
 publish.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 45 insertions(+), 11 deletions(-)
Diff
publish.shmodified
@@ -10,7 +10,14 @@ set -euo pipefail
10
# --serve After building, serve locally (implies --local)
11
# --port PORT Port for local server (default: 8000)
12
# --skip-build Skip building libraries (use existing build artifacts)
13
# --with-repl Build the WASM web REPL (requires zig on PATH)
+13
# --with-repl Force-build the WASM web REPL (on by default for a production
+14
# publish; use this to also build it under --local)
+15
# --skip-repl Skip the WASM web REPL build (explicit opt-out; NOT recommended
+16
# for a production publish — it ships a possibly-stale REPL)
+17
#
+18
# The REPL build needs zig (auto-detected from ~/.sigil/toolchain/zig) and
+19
# wasm-opt/Binaryen (on Guix: run under `guix shell binaryen`). A production
+20
# publish builds it by default so the live REPL never silently goes stale.
21
#
22
# Environment:
23
# SIGIL Path to sigil binary (default: ~/.sigil/bin/sigil)
@@ -22,7 +29,7 @@ set -euo pipefail
29
# 1. Ensures the sigil monorepo is present and built
30
# 2. Clones/fetches all extracted core library repos
31
# 3. Builds each library so API doc JSON is generated
25
# 4. Optionally builds the WASM web REPL (--with-repl)
+32
# 4. Builds the WASM web REPL (default for a production publish; --skip-repl to opt out)
33
# 5. Assembles a combined lib directory for with-api-docs
34
# 6. Builds the site
35
# 7. Optionally deploys to Codeberg Pages
@@ -31,7 +38,7 @@ LOCAL_ONLY=false
38
SERVE=false
39
PORT=8000
40
SKIP_BUILD=false
34
WITH_REPL=false
+41
WITH_REPL="" # empty = decide after parsing: a production publish builds the REPL, --local skips it
42
43
while [[ $# -gt 0 ]]; do
44
case $1 in
@@ -56,14 +63,28 @@ while [[ $# -gt 0 ]]; do
63
WITH_REPL=true
64
shift
65
;;
+66
--skip-repl)
+67
WITH_REPL=false
+68
shift
+69
;;
70
*)
71
echo "Unknown option: $1"
61
echo "Usage: $0 [--local] [--serve] [--port PORT] [--skip-build] [--with-repl]"
+72
echo "Usage: $0 [--local] [--serve] [--port PORT] [--skip-build] [--with-repl] [--skip-repl]"
73
exit 1
74
;;
75
esac
76
done
77
+78
# The web REPL is part of a PRODUCTION publish by default, so a real deploy can
+79
# never silently ship a stale REPL wasm. (It did: usesigil.org sat at 0.17.3
+80
# while the rest of the site read 0.17.6, because --with-repl was an easy-to-
+81
# forget opt-in.) A production publish now BUILDS the REPL unless --skip-repl is
+82
# passed explicitly; local dev previews (--local) skip it by default for fast
+83
# iteration (opt in with --with-repl). Either way the choice is explicit.
+84
if [[ -z "$WITH_REPL" ]]; then
+85
if [[ "$LOCAL_ONLY" == "true" ]]; then WITH_REPL=false; else WITH_REPL=true; fi
+86
fi
+87
88
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
89
cd "$SCRIPT_DIR"
90
@@ -381,12 +402,26 @@ if [[ "$SKIP_BUILD" != "true" ]]; then
402
fi
403
404
# ---------------------------------------------------------------------------
384
# Step 3.5: Build web REPL WASM (optional, requires zig)
+405
# Step 3.5: Build web REPL WASM (default for production publishes; --skip-repl to opt out)
406
# ---------------------------------------------------------------------------
407
408
if [[ "$WITH_REPL" == "true" ]]; then
+409
# Auto-detect the sigil-bundled zig so the REPL build works without a manual
+410
# PATH setup. sigil's pinned zig is cached under the monorepo's tools/zig
+411
# (populated by scripts/with-zig) and symlinked at ~/.sigil/toolchain/zig —
+412
# the same toolchain the release build uses. Only look if zig isn't already
+413
# on PATH.
+414
if ! command -v zig >/dev/null 2>&1; then
+415
for zdir in "$HOME/.sigil/toolchain/zig" "${PARENT_DIR:-}/sigil/tools/zig"; do
+416
if [[ -n "$zdir" && -x "$zdir/zig" ]]; then
+417
info "Using bundled zig at $zdir"
+418
export PATH="$zdir:$PATH"
+419
break
+420
fi
+421
done
+422
fi
423
if ! command -v zig >/dev/null 2>&1; then
389
die "--with-repl requires zig on PATH"
+424
die "REPL build requires zig: not on PATH and no bundled zig found at ~/.sigil/toolchain/zig or \$PARENT_DIR/sigil/tools/zig. Install zig, or run the monorepo's scripts/with-zig once to populate the bundled toolchain."
425
fi
426
427
# wasm-opt (Binaryen) is required for the --asyncify post-link pass that the
@@ -394,12 +429,11 @@ if [[ "$WITH_REPL" == "true" ]]; then
429
# skipped and the REPL wasm ships unresolved asyncify.* imports, so it fails
430
# to instantiate in the browser ("Import asyncify: module is not an object
431
# or function") and the REPL hangs. Fail loudly instead of shipping a broken
397
# REPL. On Guix, wasm-opt is not on PATH by default: run this whole script
398
# inside a guix shell, e.g.
399
# guix shell binaryen -- ./publish.sh --local --with-repl
400
# (prepend ~/.sigil/toolchain/zig to PATH so the bundled zig is found too).
+432
# REPL. On Guix, wasm-opt is not on PATH by default: re-run inside a guix
+433
# shell (zig is auto-detected, so binaryen is the only thing to add):
+434
# guix shell binaryen -- ./publish.sh
435
if ! command -v wasm-opt >/dev/null 2>&1; then
402
die "--with-repl requires wasm-opt (Binaryen) on PATH for the --asyncify pass. On Guix: guix shell binaryen -- ./publish.sh --with-repl ..."
+436
die "REPL build requires wasm-opt (Binaryen) for the --asyncify pass, not on PATH. On Guix: guix shell binaryen -- ./publish.sh (zig is auto-detected). To publish WITHOUT the REPL, pass --skip-repl explicitly — but that ships whatever REPL wasm is currently staged, which may be stale."
437
fi
438
439
info "Building web REPL (WASM)"