A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
site: host the playable demo on GitHub Pages (#764)
agamrafaeli-instinct478a39a0b4de
diff --git a/.github/workflows/site.yml b/.github/workflows/site.ymlindex 4b6c6ced7..1ad7c0b6c 100644--- a/.github/workflows/site.yml+++ b/.github/workflows/site.yml@@ -45,6 +45,35 @@ jobs:SITE_URL: ${{ vars.SITE_URL }}SITE_BASE: ${{ vars.SITE_BASE }}run: npm run build+ - name: Add the playable demo, when the latest release has a Pages build+ # The demo is the release's *-web-pages.zip (Build.Web -decompressionFallback; docs/RELEASING.md, step 5),+ # unpacked at /demo/. It never comes from git (the Play page explains why). No such asset yet: the site+ # deploys without it.+ if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && vars.SITE_DEPLOY == 'true'+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ run: |+ set -euo pipefail+ # Lookup failures (auth, network, rate limit) must fail the step, not deploy without the demo: no+ # error swallowing. Only two quiet skips: no releases at all, and a latest release without the zip.+ # `gh release view/download` without a tag resolve the latest non-prerelease, and every release is a+ # prerelease (docs/RELEASING.md step 6), so read the tag from the list and pass it to both calls.+ tag="$(gh release list --limit 1 --exclude-drafts --json tagName --jq '.[0].tagName // empty')"+ if [ -z "$tag" ]; then+ echo "No releases yet: deploying without the demo."+ exit 0+ fi+ asset="$(gh release view "$tag" --json assets --jq '[.assets[].name | select(endswith("-web-pages.zip"))] | first // empty')"+ if [ -z "$asset" ]; then+ echo "No *-web-pages.zip in the latest release ($tag): deploying without the demo."+ exit 0+ fi+ mkdir -p /tmp/web-pages site/dist/demo+ gh release download "$tag" --pattern "$asset" --dir /tmp/web-pages --clobber+ unzip -q -o "/tmp/web-pages/$asset" -d site/dist/demo+ test -f site/dist/demo/index.html+ jq -e '.shareable == true' site/dist/demo/event-photos.json > /dev/null+ echo "Demo at /demo/ from $asset"- name: Keep the built site for deployingif: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && vars.SITE_DEPLOY == 'true'uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 51c827bfb..5db94e954 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -56,6 +56,8 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB- Event options can now move the national Food stock: `food` is an effect target in whole units, the loadervalidates it, and the sensitive-event no-gain rule covers it (R-EFX-001 and R-EFX-002; refs #729). The Armstarget follows with its pool (#781).+- `Build.Web -decompressionFallback`: a WebGL build variant for GitHub Pages (Unity's Decompression Fallback; Pages+ cannot set response headers). When a release carries the variant's zip, the site's deploy serves it at `/demo/`.### Fixed- MATKOT's nine whole-town landmarks stand upright (refs #663, #917; owner, 18 October 2026: the models "seem to be ondiff --git a/docs/RELEASING.md b/docs/RELEASING.mdindex 844a67fbb..2e9196d69 100644--- a/docs/RELEASING.md+++ b/docs/RELEASING.md@@ -40,6 +40,28 @@ GitHub Releases page (and, from M4, on itch.io). Steps 1–3 are a normal pull rfirst, which the golden and smoke run skips: New game, and Play the recording then New game, in English and inHebrew. Each must print `PASS`. A console exception, `RECORDING failed` or `BOOT FAIL` fails it (#908).+ For the website's playable demo, build a second web variant with Unity's Decompression Fallback - GitHub Pages+ cannot set response headers, so the loader must decompress the files itself (the site's Play page explains) -+ check it and package it the same way:++ ```bash+ "$UNITY" -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -buildTarget WebGL -executeMethod Statecraft.Game.EditorTools.Build.Web -compression gzip -decompressionFallback -shareable -out Builds/Web-pages -logFile "$PWD/unity-build-web-pages.log"+ git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset+ uv run tools/web_check.py unity/Builds/Web-pages --query "golden&smoke=5" "${golden_expect[@]}" \+ --expect "SMOKE OK 5 turns 1948-10-15 3005405d64abc6e7418fa1f0d35c36ce5f64ed3af7c5a4c24a73d5dfdb16121f"+ uv run tools/web_check.py unity/Builds/Web-pages --startscreen new --timeout 300 --stall 90+ uv run tools/web_check.py unity/Builds/Web-pages --startscreen recording --timeout 300 --stall 90+ uv run tools/web_check.py unity/Builds/Web-pages --startscreen new --query lang=he --timeout 300 --stall 90+ uv run tools/web_check.py unity/Builds/Web-pages --startscreen recording --query lang=he --timeout 300 --stall 90+ bash scripts/oss/package_web.sh unity/Builds/Web-pages unity/Builds/statecraft-israel-vX.Y.Z-web-pages.zip+ ```++ When the latest release carries this `statecraft-israel-vX.Y.Z-web-pages.zip`, the site's deploy+ (`.github/workflows/site.yml`) unpacks it at `/demo/`, so the demo is live at the site's `/demo/` after the next+ deploy (`gh workflow run site.yml` starts one on demand). Until then the site deploys without it, and the Play+ page keeps saying there is no hosted build. Updating the Play page (and the README's Play section) to link to+ `/demo/` is a follow-up step when the first such release ships, not part of this release flow.+`package_web.sh` copies the licence and attribution files into the build folder, then runs`tools/package_release.py`, M3's sensitivity gate, which zips the folder and prints `PACKAGED …` or`PACKAGE REFUSED …`. It refuses a build that was not made with `-shareable` (the build's `event-photos.json` says@@ -93,7 +115,8 @@ GitHub Releases page (and, from M4, on itch.io). Steps 1–3 are a normal pull rgit tag -a vX.Y.Z -m "Statecraft: Israel vX.Y.Z" # skip if "Desktop builds" already made itgit push origin vX.Y.Zgh release create vX.Y.Z --prerelease --title "vX.Y.Z" --notes-file <notes from CHANGELOG.md, saying "unchecked"> \- unity/Builds/statecraft-israel-vX.Y.Z-web.zip <out>/statecraft-israel-vX.Y.Z-windows-x64.zip \+ unity/Builds/statecraft-israel-vX.Y.Z-web.zip unity/Builds/statecraft-israel-vX.Y.Z-web-pages.zip \+ <out>/statecraft-israel-vX.Y.Z-windows-x64.zip \<out>/statecraft-israel-vX.Y.Z-linux-x64.tar.gz <out>/statecraft-israel-vX.Y.Z-macos-universal.zip```diff --git a/sim/Statecraft.Sim.Tests/GoldenManifestTests.cs b/sim/Statecraft.Sim.Tests/GoldenManifestTests.csindex 9c1b634b5..d47c68f56 100644--- a/sim/Statecraft.Sim.Tests/GoldenManifestTests.cs+++ b/sim/Statecraft.Sim.Tests/GoldenManifestTests.cs@@ -71,4 +71,19 @@ public class GoldenManifestTestsAssert.Contains($"Hash1952 = \"{GoldenRun.Hash1952}\"", after);Assert.NotEqual(src, after);}-}++ [Fact]+ public void EveryWebCheckExpectInReleasingShowsTheManifestHash()+ {+ // RELEASING.md runs web_check on two builds (the release zip and the Pages demo): both take the goldens from the manifest loop and pin smoke5+ var doc = Text("docs", "RELEASING.md");+ var webChecks = System.Text.RegularExpressions.Regex.Matches(doc, @"web_check\.py unity/Builds/\S+ --query ""golden&smoke=5""[^\n]*");+ Assert.True(webChecks.Count >= 2, $"expected the golden web_check of both web builds in docs/RELEASING.md, found {webChecks.Count}");+ foreach (System.Text.RegularExpressions.Match m in webChecks)+ Assert.Contains("\"${golden_expect[@]}\"", m.Value);+ var smokes = System.Text.RegularExpressions.Regex.Matches(doc, @"--expect ""SMOKE OK 5 turns 1948-10-15 ([0-9a-f]{64})""");+ Assert.True(smokes.Count >= 2, $"expected the smoke5 --expect line of both web builds, found {smokes.Count}");+ foreach (System.Text.RegularExpressions.Match m in smokes)+ Assert.True(GoldenManifest.Expected("smoke5") == m.Groups[1].Value, $"docs/RELEASING.md shows a stale smoke5 hash: {m.Value}");+ }+}\ No newline at end of filediff --git a/site/README.md b/site/README.mdindex c4bf46c46..f0f600e30 100644--- a/site/README.md+++ b/site/README.md@@ -56,4 +56,4 @@ The site lives at `https://eyalgolan.github.io/statecraft-israel/` until there i## Hosting the game here-GitHub Pages cannot set response headers, so the browser build must use Unity's Decompression Fallback and stay single-threaded. The Play page explains this; today `Build.Web` turns the fallback off.+GitHub Pages cannot set response headers, so the browser build for this site is made with Unity's Decompression Fallback and stays single-threaded (the Play page explains both). `docs/RELEASING.md` step 5 builds it as `statecraft-israel-vX.Y.Z-web-pages.zip` (`Build.Web -decompressionFallback`) on each release, and the deploy step in `.github/workflows/site.yml` unpacks the latest release's zip at `/demo/` - at deploy time, never from git. Until a release carries one, the site deploys without the demo and the Play page keeps saying there is no hosted build. Updating the Play page (and the root README's Play section) to link to `/demo/` is a follow-up step when the first such release ships.diff --git a/site/src/content/en/play.md b/site/src/content/en/play.mdindex b63c38cdf..a857eb3cc 100644--- a/site/src/content/en/play.md+++ b/site/src/content/en/play.md@@ -17,7 +17,7 @@ Turns from 15 May 1948 to the end of 1951: the start screen, the 1948 map with iThis site is served by GitHub Pages, which cannot set response headers. That decides how the browser build must be made before it can go here:-- **Decompression Fallback.** Unity's Brotli and gzip builds need the server to send `Content-Encoding`, which GitHub Pages cannot do. A build for this site needs Unity's Decompression Fallback: the compressed files get the `.unityweb` extension and the loader decompresses them in JavaScript, at the cost of a larger loader. Unity recommends it when the server cannot be configured ([Unity manual: deploying a Web application](https://docs.unity3d.com/6000.0/Documentation/Manual/webgl-deploying.html)). Today `Build.Web` in `unity/Assets/Editor/Build.cs` always turns the fallback off, because itch.io serves `.br` files correctly; a Pages build needs an option to turn it on.+- **Decompression Fallback.** Unity's Brotli and gzip builds need the server to send `Content-Encoding`, which GitHub Pages cannot do. A build for this site needs Unity's Decompression Fallback: the compressed files get the `.unityweb` extension and the loader decompresses them in JavaScript, at the cost of a larger loader. Unity recommends it when the server cannot be configured ([Unity manual: deploying a Web application](https://docs.unity3d.com/6000.0/Documentation/Manual/webgl-deploying.html)). `Build.Web` in `unity/Assets/Editor/Build.cs` turns the fallback on with `-decompressionFallback` (off by default, because itch.io serves `.br` files correctly); `docs/RELEASING.md` builds the Pages variant with it.- **Single-threaded.** Multithreaded Web builds need the COOP and COEP headers, which GitHub Pages cannot send either. The project's builds are single-threaded now (`webGLThreadsSupport: 0`), and they must stay that way for this site.- **Shareable.** Only a `-shareable` build may be published: it refuses while any sensitive event or photograph lacks its sensitivity review ([docs/m3-release.md](https://github.com/eyalgolan/statecraft-israel/blob/main/docs/m3-release.md)).-- **Not committed.** The M3 build was 23 MB in 51 files, and no file in the repository may pass 10 MB. The deploy workflow would add the build to the site at deploy time, not from git.+- **Not committed.** The M3 build was 23 MB in 51 files, and no file in the repository may pass 10 MB. The deploy workflow adds the latest release's Pages build to the site at `/demo/` at deploy time, not from git.diff --git a/site/src/content/he/play.md b/site/src/content/he/play.mdindex c6578303e..c4b6a446b 100644--- a/site/src/content/he/play.md+++ b/site/src/content/he/play.md@@ -17,7 +17,7 @@האתר מוגש מ־GitHub Pages, שאינו יכול לקבוע כותרות תגובה (response headers). זה קובע איך צריך לבנות את גרסת הדפדפן לפני שאפשר להעלות אותה לכאן:-- **Decompression Fallback.** גרסאות Brotli ו־gzip של Unity דורשות שהשרת ישלח <span dir="ltr">`Content-Encoding`</span>, ו־GitHub Pages לא יכול. גרסה לאתר הזה צריכה את ה־Decompression Fallback של Unity: הקבצים הדחוסים מקבלים את הסיומת <span dir="ltr">`.unityweb`</span>, והטוען פורס אותם ב־JavaScript, במחיר טוען גדול יותר. Unity ממליצה על כך כשאי אפשר להגדיר את השרת ([המדריך של Unity, באנגלית](https://docs.unity3d.com/6000.0/Documentation/Manual/webgl-deploying.html)). כיום <span dir="ltr">`Build.Web`</span> שב־<span dir="ltr">`unity/Assets/Editor/Build.cs`</span> תמיד מכבה את האפשרות, כי itch.io מגיש קובצי <span dir="ltr">`.br`</span> כראוי; לגרסה ל־Pages צריך אפשרות שמדליקה אותה.+- **Decompression Fallback.** גרסאות Brotli ו־gzip של Unity דורשות שהשרת ישלח <span dir="ltr">`Content-Encoding`</span>, ו־GitHub Pages לא יכול. גרסה לאתר הזה צריכה את ה־Decompression Fallback של Unity: הקבצים הדחוסים מקבלים את הסיומת <span dir="ltr">`.unityweb`</span>, והטוען פורס אותם ב־JavaScript, במחיר טוען גדול יותר. Unity ממליצה על כך כשאי אפשר להגדיר את השרת ([המדריך של Unity, באנגלית](https://docs.unity3d.com/6000.0/Documentation/Manual/webgl-deploying.html)). <span dir="ltr">`Build.Web`</span> שב־<span dir="ltr">`unity/Assets/Editor/Build.cs`</span> מדליק את האפשרות עם <span dir="ltr">`-decompressionFallback`</span> (כבויה כברירת מחדל, כי itch.io מגיש קובצי <span dir="ltr">`.br`</span> כראוי); <span dir="ltr">`docs/RELEASING.md`</span> בונה איתה את גרסת ה־Pages.- **תהליכון יחיד.** גרסאות Web מרובות תהליכונים דורשות את הכותרות COOP ו־COEP, וגם אותן GitHub Pages לא שולח. הגרסאות של הפרויקט בנויות היום בתהליכון יחיד (<span dir="ltr">`webGLThreadsSupport: 0`</span>), וכך הן צריכות להישאר בשביל האתר הזה.- **גרסה לשיתוף.** מותר לפרסם רק גרסה שנבנתה עם <span dir="ltr">`-shareable`</span>: היא מסרבת להיבנות כל עוד לאירוע או לצילום רגיש חסרה בדיקת רגישות ([<span dir="ltr">docs/m3-release.md</span>](https://github.com/eyalgolan/statecraft-israel/blob/main/docs/m3-release.md), באנגלית).-- **לא נשמרת ב־git.** גרסת M3 שקלה 23 מגה־בייט ב־51 קבצים, ושום קובץ במאגר לא יכול לעבור 10 מגה־בייט. תהליך הפריסה יוסיף את הגרסה לאתר בזמן הפריסה, לא מתוך git.+- **לא נשמרת ב־git.** גרסת M3 שקלה 23 מגה־בייט ב־51 קבצים, ושום קובץ במאגר לא יכול לעבור 10 מגה־בייט. תהליך הפריסה מוסיף את גרסת ה־Pages של המהדורה האחרונה לאתר תחת <span dir="ltr">`/demo/`</span> בזמן הפריסה, לא מתוך git.diff --git a/unity/Assets/Editor/Build.cs b/unity/Assets/Editor/Build.csindex 86bbf6091..a1de04659 100644--- a/unity/Assets/Editor/Build.cs+++ b/unity/Assets/Editor/Build.cs@@ -15,7 +15,9 @@ namespace Statecraft.Game.EditorTools/// first (IPreprocessBuildWithReport), and CollectionImport.BuildBundles puts The 1948 Collection's streamed bundles in/// StreamingAssets/collection. Exits non-zero on failure./// Web: Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -buildTarget WebGL -executeMethod Statecraft.Game.EditorTools.Build.Web- /// [-compression disabled|gzip|brotli] [-out Builds/Web-disabled] [-textureSubtarget dxt|etc2|astc]+ /// [-compression disabled|gzip|brotli] [-decompressionFallback] [-out Builds/Web-disabled] [-textureSubtarget dxt|etc2|astc]+ /// (-decompressionFallback: Unity's Decompression Fallback, for hosts that cannot set response headers,+ /// like GitHub Pages; the website's demo build uses it, docs/RELEASING.md)/// (-textureSubtarget: the compressed format of every automatic texture; the default build is DXT, for desktop/// browsers; astc or etc2 makes a build for browsers without S3TC, as on phones)/// Mac: Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -buildTarget OSXUniversal -executeMethod Statecraft.Game.EditorTools.Build.Mac@@ -180,7 +182,7 @@ namespace Statecraft.Game.EditorToolsvar name = Arg("-compression") ?? "disabled";ProjectSetup.Apply();PlayerSettings.WebGL.compressionFormat = Compression(name);- PlayerSettings.WebGL.decompressionFallback = false; // itch.io and web_check send .gz/.br with Content-Encoding; the release is gzip (#879)+ PlayerSettings.WebGL.decompressionFallback = Flag("-decompressionFallback"); // off by default: itch.io and web_check send .gz/.br with Content-Encoding (#879); Pages needs the fallbackvar savedSubtarget = EditorUserBuildSettings.webGLBuildSubtarget;var sub = TextureSubtarget(Arg("-textureSubtarget"));if (sub.HasValue) EditorUserBuildSettings.webGLBuildSubtarget = sub.Value;