#!/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) # # 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} [ -f build/version.json ] || { echo "no build/version.json: run tools/export.sh first"; exit 1; } [ -f build/Emberwild-trailer.mp4 ] || { echo "no trailer: run tools/trailer/make_trailer.sh first"; exit 1; } rm -rf build/site && mkdir -p build/site cp build/Emberwild-trailer.mp4 build/site/trailer.mp4 cp build/trailer/poster.jpg build/site/poster.jpg python3 - "$REPO" <<'EOF' import html, json, sys repo = sys.argv[1].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", }.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