- Rename player-asbuilt.html → stage.html (the pedalboard build). Update build.sh + deploy.sh (deploy now also removes the old player-asbuilt.html from the web root) and the cross-links in player.html / stage.html. - New /micro.html — a stripped-down home-practice metronome on the same RP2040 firmware. Hardware is just: ONE depressable scroll/rotary encoder, a red 7-segment LED display, a speaker, and USB-C for power. The encoder does everything: spin = tempo, press = start/stop, hold + spin = switch track (the LED shows the track number, with BPM / TRACK / ▶ indicators). Tracks = the editor's seed grooves flattened (23). Shares src/engine.js, setlists.js, base.css; synth-only; steady practice loop (ramps/bars ignored). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
3.3 KiB
Bash
Executable file
65 lines
3.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Deploy the metronome to the Caddy web root that serves
|
|
# https://metronome.varasys.io
|
|
#
|
|
# Caddy config: /var/lib/caddy/Caddyfile (metronome.varasys.io:8443 block)
|
|
# Bind-mount: /etc/containers/systemd/caddy.container
|
|
#
|
|
# The web root is bind-mounted read-only into the Caddy container and
|
|
# served by file_server, which picks up changes immediately — so a plain
|
|
# file copy is all that's needed (no container restart).
|
|
set -euo pipefail
|
|
|
|
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
DEST_DIR="/var/lib/caddy/www/metronome"
|
|
DIST_DIR="$SRC_DIR/dist"
|
|
|
|
[[ -f "$SRC_DIR/index.html" ]] || { echo "error: $SRC_DIR/index.html not found" >&2; exit 1; }
|
|
[[ -d "$DEST_DIR" ]] || { echo "error: web root $DEST_DIR is missing — is Caddy set up?" >&2; exit 1; }
|
|
|
|
# Assemble the self-contained pages (inlines assets/ into dist/). dist/ is git-ignored.
|
|
"$SRC_DIR/build.sh"
|
|
[[ -f "$DIST_DIR/index.html" ]] || { echo "error: build did not produce $DIST_DIR/index.html" >&2; exit 1; }
|
|
|
|
# --- compute build version ---------------------------------------------------
|
|
# Formal build: clean tree on a commit tagged v<VERSION> -> "X.Y.Z"
|
|
# Dev build: anything else -> "X.Y.Z-dev.<utc-ts>.<sha>[.dirty]"
|
|
VER="$(cat "$SRC_DIR/VERSION" 2>/dev/null || echo 0.0.0)"
|
|
cd "$SRC_DIR"
|
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
tag="$(git describe --exact-match --tags HEAD 2>/dev/null || true)"
|
|
dirty=""; [[ -n "$(git status --porcelain 2>/dev/null)" ]] && dirty=".dirty"
|
|
if [[ "$tag" == "v$VER" && -z "$dirty" ]]; then
|
|
BUILD="$VER" # formal release
|
|
else
|
|
BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ).g$(git rev-parse --short HEAD 2>/dev/null || echo nogit)$dirty"
|
|
fi
|
|
else
|
|
BUILD="$VER-dev.$(date -u +%Y%m%dT%H%M%SZ)" # not a git checkout
|
|
fi
|
|
|
|
# stamp the version into the built copy only (source stays clean)
|
|
sed "s|const APP_VERSION = \"[^\"]*\";|const APP_VERSION = \"$BUILD\";|" "$DIST_DIR/index.html" > "$DEST_DIR/index.html"
|
|
echo "deployed v$BUILD ($(stat -c '%s' "$DEST_DIR/index.html") bytes) -> $DEST_DIR"
|
|
sed "s|const APP_VERSION = \"[^\"]*\";|const APP_VERSION = \"$BUILD\";|" "$DIST_DIR/player.html" > "$DEST_DIR/player.html"
|
|
echo "deployed player.html ($(stat -c '%s' "$DEST_DIR/player.html") bytes)"
|
|
sed "s|const APP_VERSION = \"[^\"]*\";|const APP_VERSION = \"$BUILD\";|" "$DIST_DIR/stage.html" > "$DEST_DIR/stage.html"
|
|
echo "deployed stage.html ($(stat -c '%s' "$DEST_DIR/stage.html") bytes)"
|
|
sed "s|const APP_VERSION = \"[^\"]*\";|const APP_VERSION = \"$BUILD\";|" "$DIST_DIR/micro.html" > "$DEST_DIR/micro.html"
|
|
echo "deployed micro.html ($(stat -c '%s' "$DEST_DIR/micro.html") bytes)"
|
|
rm -f "$DEST_DIR/player-asbuilt.html" # renamed to stage.html
|
|
|
|
# If real audio samples are added later (see the plan's GM-sample note),
|
|
# sync that directory too.
|
|
if [[ -d "$SRC_DIR/samples" ]]; then
|
|
rsync -a --delete "$SRC_DIR/samples/" "$DEST_DIR/samples/"
|
|
echo "synced samples/ -> $DEST_DIR/samples"
|
|
fi
|
|
|
|
# Smoke test: Caddy serves on :8443 with tls internal; resolve the host
|
|
# to localhost so SNI matches the site block.
|
|
if command -v curl >/dev/null 2>&1; then
|
|
code=$(curl -sk --resolve metronome.varasys.io:8443:127.0.0.1 \
|
|
https://metronome.varasys.io:8443/ -o /dev/null -w '%{http_code}' || echo "??")
|
|
echo "smoke test: metronome.varasys.io -> HTTP $code"
|
|
fi
|