Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Release: build the web zip with cargo xtask web (wasm-bindgen), not trunk

Brandon Thomasaeaf4154f70f
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5d94d8a4e..7b04f35fe 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -209,7 +209,7 @@ jobs:
env:
LIGHTCRAFT_VERSION: ${{ needs.version.outputs.version }}
LIGHTCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}
- TRUNK_VERSION: 0.21.14
+ WASM_BINDGEN_VERSION: 0.2.129
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
@@ -218,11 +218,12 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
key: release-web
- - name: Install trunk
+ - name: Install wasm-bindgen CLI
run: |
- curl -fsSL "https://github.com/trunk-rs/trunk/releases/download/v${TRUNK_VERSION}/trunk-x86_64-unknown-linux-gnu.tar.gz" \
- | tar -xz -C "$HOME/.cargo/bin" trunk
- trunk --version
+ # Must match the wasm-bindgen version in Cargo.lock exactly (cargo xtask web checks it).
+ command -v wasm-bindgen >/dev/null && wasm-bindgen --version | grep -q "$WASM_BINDGEN_VERSION" \
+ || cargo install wasm-bindgen-cli --version "$WASM_BINDGEN_VERSION" --locked
+ wasm-bindgen --version
- name: Apply version override
if: inputs.version != ''
run: cargo xtask version set "$LIGHTCRAFT_VERSION"
diff --git a/packaging/web/package.sh b/packaging/web/package.sh
index 52055b9ca..8e8f0cf08 100755
--- a/packaging/web/package.sh
+++ b/packaging/web/package.sh
@@ -3,8 +3,8 @@
#
# Usage: packaging/web/package.sh [--skip-build]
#
-# Needs: trunk (brew install trunk / cargo install trunk --locked) and the wasm32-unknown-unknown
-# target. The zip holds a self-contained static site in lightcraft-web-<version>/ that works
+# Needs: the wasm32-unknown-unknown target and the wasm-bindgen CLI at the version in Cargo.lock
+# (see docs/web.md); `cargo xtask web` builds it. The zip holds a self-contained static site in lightcraft-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
@@ -12,13 +12,12 @@ set -euo pipefail
HERE="$ROOT/packaging/web"
if [ "${1:-}" != "--skip-build" ]; then
- command -v trunk >/dev/null || { echo "error: trunk not found (cargo install trunk --locked)" >&2; exit 1; }
- (cd "$ROOT/apps/lightcraft-web" && trunk build --release)
+ (cd "$ROOT" && cargo xtask web)
fi
-SITE="$ROOT/dist/web"
+SITE="$CARGO_TARGET_DIR/web"
[ -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 (public_url = "./" in Trunk.toml).
+# 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