#!/bin/sh # Builds the download page into build/site/ for the release in # build/version.json (made by tools/export.sh): # # tools/site/make_site.sh # # build/site/index.html the page, with this release's download links # build/site/poster.jpg the trailer's title frame # build/site/trailer.mp4 the trailer (tools/trailer/make_trailer.sh) # build/site/shots/ the screenshots (tools/site/make_shots.sh) # # Copy the folder to any static web host. Gitea itself won't serve HTML, so # the page lives elsewhere and links to the files on the Gitea release. # Rebuild it after each release (the links name the version). cd "$(dirname "$0")/../.." || exit 1 REPO=${REPO:-https://git.psbailey.uk/Admin/Emberwild} SITE=${SITE:-https://cinderwild.psbailey.uk} # (where the page is served: for link previews) SHOTS="meadow hut wolves winter cove treasure crabs" [ -f build/version.json ] || { echo "no build/version.json: run tools/export.sh first"; exit 1; } [ -f build/Cinderwild-trailer.mp4 ] || { echo "no trailer: run tools/trailer/make_trailer.sh first"; exit 1; } for s in $SHOTS; do [ -f "build/shots/$s.jpg" ] || { echo "no build/shots/$s.jpg: run tools/site/make_shots.sh first"; exit 1; } done rm -rf build/site && mkdir -p build/site cp build/Cinderwild-trailer.mp4 build/site/trailer.mp4 cp build/trailer/poster.jpg build/site/poster.jpg mkdir -p build/site/shots for s in $SHOTS; do cp "build/shots/$s.jpg" build/site/shots/; done python3 - "$REPO" "$SITE" <<'EOF' import html, json, sys repo = sys.argv[1].rstrip("/") site = sys.argv[2].rstrip("/") v = json.load(open("build/version.json")) tag = "v" + v["version"] def dl(plat): d = v["downloads"].get(plat) if not d: return repo + "/releases", "see all releases" return "%s/releases/download/%s/%s" % (repo, tag, d["file"]), "%.0f MB" % (d["size"] / 1e6) mac_url, mac_size = dl("macos") win_url, win_size = dl("windows") page = open("tools/site/index.html").read() for k, val in { "VERSION": v["version"], "DATE": v.get("date", ""), "NOTES": v.get("notes", ""), "MAC_URL": mac_url, "MAC_SIZE": mac_size, "WIN_URL": win_url, "WIN_SIZE": win_size, "RELEASES_URL": repo + "/releases", "REPO_URL": repo, "SITE_URL": site, }.items(): page = page.replace("{{%s}}" % k, html.escape(str(val), quote=True)) assert "{{" not in page, "a placeholder was left unfilled" open("build/site/index.html", "w").write(page) print("built build/site/ for %s:\n %s\n %s" % (v["version"], mac_url, win_url)) EOF # The help pages (guide.html): the written guide plus tables from the game's # own data, which Godot dumps from the scripts so they're exact. . tools/godot_env.sh DATA=build/site_data.json "$GODOT" --headless --path . --script res://tools/site/dump_data.gd -- "$PWD/$DATA" >/dev/null 2>&1 \ || { echo "couldn't dump the game data for the guide"; exit 1; } python3 tools/site/make_guide.py "$DATA" build/site || exit 1 rm -f "$DATA" # Cloudflare Pages refuses any file over 25 MiB: catch it here, not at deploy. LIMIT=26214400 for f in build/site/* build/site/shots/*; do [ -f "$f" ] || continue s=$(stat -f %z "$f" 2>/dev/null || stat -c %s "$f") if [ "$s" -ge "$LIMIT" ]; then echo "$f is $s bytes: over Cloudflare Pages' 25 MiB limit (re-encode the trailer smaller)"; exit 1 fi done