Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990#!/usr/bin/env bashset -euo pipefail
# Pass --production (or set PROTOKILL_PRODUCTION=1) for a release deploy; it# hides the dev build stamp. Without it, this is treated as a preview build.PRODUCTION="${PROTOKILL_PRODUCTION:-0}"case "${1:-}" in --production) PRODUCTION=1 ;; "") ;; *) echo "usage: $0 [--production]" >&2; exit 2 ;;esac
# Source cargo environment (needed when rustup was installed in a prior CI phase).[[ -f "$HOME/.cargo/env" ]] && source "$HOME/.cargo/env"
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"DEST="$REPO_ROOT/output"BUNDLE="$REPO_ROOT/target/bevy_web/web-release/protokill_wasm_frontend"FONTS_DIR="$REPO_ROOT/crates/protokill_wasm_frontend/assets/fonts/.fetched"
if [[ "$PRODUCTION" == "1" ]]; then capture_mode=productionelse capture_mode=devfi# shellcheck source=build-stamp.shsource "$REPO_ROOT/scripts/build-stamp.sh"capture_build_stamp "$capture_mode"build_info_json > "$REPO_ROOT/web/build-info.json"export_build_stamp
echo "==> Fetching terminal fonts""$REPO_ROOT/scripts/fetch-fonts.sh"
echo "==> Building ATProto JS bundle"(cd "$REPO_ROOT/web" && npm install --silent && npm run build)
echo "==> Building WASM app"cd "$REPO_ROOT"bevy build --yes --release -p protokill_wasm_frontend web --bundle
echo "==> Assembling output"rm -rf "$DEST"mkdir -p "$DEST"cp -r "$BUNDLE/." "$DEST/"rm -rf "$DEST/node_modules" "$DEST/package.json" "$DEST/package-lock.json"
# Copy static assets not included in the bevy bundle.# Note: static/index.html is the pre-launch placeholder — the real# index.html comes from web/index.html via the bevy bundle above.cp "$REPO_ROOT/static/favicon.ico" "$DEST/"cp "$REPO_ROOT/static/client-metadata.json" "$DEST/"cp "$REPO_ROOT/static/privacy.html" "$DEST/"cp "$REPO_ROOT/static/client-metadata-preview.json" "$DEST/"
# The fonts are fetched, so ship their upstream licences beside them.for licence in "$FONTS_DIR"/*/*.txt; do face="$(basename "$(dirname "$licence")")" mkdir -p "$DEST/fonts/$face" cp "$licence" "$DEST/fonts/$face/"done
# Precompress the wasm. Amplify uploads every artifact (`**/*` in amplify.yml),# so the files are available at `<name>.wasm.br`/`.gz`; serving them for# `<name>.wasm` still needs a custom-header or rewrite rule in the Amplify# console. `brotli` is not in every build image, so fall back to Node's zlib,# which the `npm install` above guarantees.WASM="$DEST/build/protokill_wasm_frontend_bg.wasm"if command -v brotli >/dev/null 2>&1; then brotli --quality=11 --force "$WASM"else node -e ' const fs = require("node:fs"); const zlib = require("node:zlib"); const file = process.argv[1]; const input = fs.readFileSync(file); fs.writeFileSync(file + ".br", zlib.brotliCompressSync(input, { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 11, [zlib.constants.BROTLI_PARAM_SIZE_HINT]: input.length, }, })); ' "$WASM"fiecho "Precompressed $WASM.br"gzip --best --force --keep --no-name "$WASM"echo "Precompressed $WASM.gz"
echo "Deployed to $DEST"