Files
effectcraft/packaging/web/package.sh
T
Brandon ThomasandClaude Opus 5.5 935cf691d1 Release fixes: CLI --version, ALSA on Linux, web build via xtask, xtask version
- effectcraft-cli: support --version/-V/version (the packaging smoke tests call it).
- Linux release job installs libasound2-dev for alsa-sys; deb/rpm depend on
  libasound2/alsa-lib; Flatpak gets --socket=pulseaudio.
- packaging/web/package.sh builds with `cargo xtask web` (wasm-bindgen) and zips
  <target>/web/dist; the release job installs wasm-bindgen-cli 0.2.129.
- xtask: version.rs (ported from PhotoCraft) called helpers that don't exist here,
  so xtask didn't compile; use the local run() and wire up `cargo xtask version`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-02 16:19:03 -04:00

39 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the browser version and zip it: $DIST/effectcraft-web-<version>.zip
#
# Usage: packaging/web/package.sh [--skip-build]
#
# Needs: the wasm32-unknown-unknown target and the wasm-bindgen CLI at the version in Cargo.lock;
# `cargo xtask web` builds it. The zip holds a self-contained static site in effectcraft-web-<version>/ that works
# from any URL path and inside an <iframe>. Hosting notes: packaging/web/README.md.
set -euo pipefail
# shellcheck source=../env.sh
. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"
HERE="$ROOT/packaging/web"
if [ "${1:-}" != "--skip-build" ]; then
(cd "$ROOT" && cargo xtask web)
fi
SITE="$CARGO_TARGET_DIR/web/dist"
[ -f "$SITE/index.html" ] || { echo "error: $SITE/index.html missing; run without --skip-build" >&2; exit 1; }
# Paths must be relative so the site works under any prefix.
if grep -Eq '(src|href)="/[^/]' "$SITE/index.html"; then
echo "error: $SITE/index.html has root-absolute URLs; it would break when served from a sub-path" >&2
exit 1
fi
NAME="effectcraft-web-$VERSION"
WORK="$CARGO_TARGET_DIR/web-package"
rm -rf "$WORK"
mkdir -p "$WORK/$NAME"
cp -R "$SITE/." "$WORK/$NAME/"
# Sample server configs (MIME type, caching, compression); harmless where unused.
cp "$HERE/_headers" "$HERE/.htaccess" "$WORK/$NAME/"
cp "$HERE/README.md" "$WORK/$NAME/HOSTING.md"
copy_docs "$WORK/$NAME"
rm -f "$DIST/$NAME.zip"
(cd "$WORK" && zip -qr9 "$DIST/$NAME.zip" "$NAME")
echo "wrote $DIST/$NAME.zip"
ls -lh "$DIST/$NAME.zip"