seriesoftubes/scripts/build.sh
Frederic Jung e082d6fc60
Persist games across reloads and announce new releases
- Autosave every five seconds while playing, plus on pagehide and when
  the tab is hidden. On load, a saved game resumes immediately (same
  speed and camera) instead of waiting behind the title screen.
- The build turns this version's CHANGELOG section into release notes:
  baked into the page for a one-time "What's new" card for returning
  players, and published as /version.json.
- Open games poll /version.json every 10 minutes and when the tab comes
  back into view; if a newer release is out, a banner offers to save
  and reload.
- "Start a new network" moves into the help screen, behind a confirm.
2026-10-23 11:42:28 +02:00

31 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Builds the deployable site into _site/: copies site/ and stamps the version
# (from package.json) and the build date into the pages that carry them.
set -euo pipefail
cd "$(dirname "$0")/.."
VERSION="${VERSION:-$(node -p "require('./package.json').version")}"
BUILD_DATE="${BUILD_DATE:-$(date -u +%Y-%m-%d)}"
rm -rf _site
cp -R site _site
for f in _site/index.html _site/sitemap.xml _site/llms.txt; do
sed -i.bak -e "s/__VERSION__/${VERSION}/g" -e "s/__BUILD_DATE__/${BUILD_DATE}/g" "$f"
rm -f "$f.bak"
done
# Release notes for this version, baked into the page ("What's new") and
# published as version.json so open games can spot a newer release.
NOTES="$(node scripts/release-notes.js "$VERSION")"
node -e '
const fs=require("fs"),[,v,d,notes]=process.argv;
const f="_site/index.html";
fs.writeFileSync(f,fs.readFileSync(f,"utf8").replace("/*__RELEASE_NOTES__*/[]",notes));
fs.writeFileSync("_site/version.json",JSON.stringify({version:v,date:d,notes:JSON.parse(notes)},null,2)+"\n");
' "$VERSION" "$BUILD_DATE" "$NOTES"
if grep -rl "__VERSION__\|__BUILD_DATE__" _site >/dev/null; then
echo "error: unreplaced placeholders left in _site" >&2
exit 1
fi
echo "Built Series of Tubes ${VERSION} (${BUILD_DATE}) into _site/"