Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

build(oss): release gate, notices inside the shipped zip, full policy check in CI

eyalgolan3fd3777b9b4d
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 377fbedd7..a090ad025 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -56,6 +56,10 @@ jobs:
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: "0.12.5"
+ # Dependencies are declared inline (uv run --with, # /// script), so there is no lock file to hash.
+ cache-dependency-glob: |
+ tools/**/*.py
+ scripts/oss/**/*.py
- name: Data tool tests
run: uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q
@@ -70,10 +74,14 @@ jobs:
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: "0.12.5"
+ # Dependencies are declared inline (uv run --with, # /// script), so there is no lock file to hash.
+ cache-dependency-glob: |
+ tools/**/*.py
+ scripts/oss/**/*.py
- name: Policy checker tests
run: uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q
- name: Licences, provenance, secrets and required files at the tip
- run: uv run scripts/oss/check_repo.py --only secrets,emails,home-paths,sizes,symlinks
+ run: uv run scripts/oss/check_repo.py
changelog:
name: Changelog
@@ -88,6 +96,10 @@ jobs:
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
version: "0.12.5"
+ # Dependencies are declared inline (uv run --with, # /// script), so there is no lock file to hash.
+ cache-dependency-glob: |
+ tools/**/*.py
+ scripts/oss/**/*.py
- name: A user-visible change carries a CHANGELOG line or the no-changelog label
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0a53e322a..30e4941f5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -39,7 +39,7 @@ Follow [docs/dev-setup.md](docs/dev-setup.md). In short:
- the tools tests (they need the .NET SDK too: one runs the sim's release gate):
`uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q`;
- the repository policy checks:
- `uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q` and `uv run scripts/oss/check_repo.py --only secrets,emails,home-paths,sizes,symlinks` (the command CI runs);
+ `uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q` and `uv run scripts/oss/check_repo.py` (the command CI runs);
- Unity EditMode tests, if you touched `unity/` (`-buildTarget OSXUniversal` keeps an earlier WebGL build from leaving the editor on the wrong platform):
`"$UNITY" -batchmode -projectPath unity -buildTarget OSXUniversal -runTests -testPlatform EditMode -testResults "$PWD/unity-editmode.xml" -logFile unity-tests.log`. There must be 0 `warning CS` in the log.
4. **Text the player sees** has no internal ids, gives dates as "15 May 1948", and shows money as "IL 1.2m" or "$1.2m". The tests enforce this.
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
new file mode 100644
index 000000000..62bbbbc87
--- /dev/null
+++ b/docs/RELEASING.md
@@ -0,0 +1,72 @@
+# Releasing
+
+A release is a tagged commit on `main` with a CHANGELOG section and, from the first shared build on, a WebGL zip on the
+GitHub Releases page (and, from M4, on itch.io). Steps 1–4 are a normal pull request. Steps 5–7 are owner steps.
+
+1. **Choose the version** (Semantic Versioning, pre-1.0 while the game is pre-release).
+2. **Bump every version site in one pull request:** `sim/Statecraft.Sim/SimInfo.cs` (`Version`) and
+ `unity/ProjectSettings/ProjectSettings.asset` (`bundleVersion`). Then move the `## [Unreleased]` entries in
+ `CHANGELOG.md` under `## [X.Y.Z] - YYYY-MM-DD` and leave an empty `## [Unreleased]` above it.
+ `scripts/oss/tests/test_release.py::test_versions_agree` fails if the three disagree.
+3. **Run the release gate** on the merged `main`: `bash scripts/oss/release_gate.sh`. It must print
+ `RELEASE GATE OK`. It refuses while an owner decision is open (including D10, history acknowledgement, and D11, the
+ sensitivity review), while an asset row is `owner-verify`, while the sim's sensitivity gate refuses `content/`, or
+ while the history scan shows an open secret-shape row.
+4. **Merge** the pull request (squash).
+5. **Build and package** on the owner's machine, from the merged `main`:
+
+ ```bash
+ "$UNITY" -batchmode -quit -projectPath unity -buildTarget WebGL -executeMethod Statecraft.Game.EditorTools.Build.Web -compression brotli -shareable -logFile "$PWD/unity-build-web-br.log"
+ git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset
+ uv run tools/web_check.py unity/Builds/Web-brotli --query "golden&smoke=5" --expect "GOLDEN OK 1950" --expect "GOLDEN OK 1952" --expect "SMOKE OK 5 turns"
+ bash scripts/oss/package_web.sh unity/Builds/Web-brotli unity/Builds/statecraft-israel-vX.Y.Z-web.zip
+ ```
+
+ `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 then lists the zip, and prints the SHA-256 and `OK: notices inside …`. If it prints anything
+ else, stop. This one zip is the file for GitHub Releases and for the M4 itch.io upload (`docs/m3-release.md`); never
+ zip a build by hand.
+6. **Tag and publish (owner):**
+
+ ```bash
+ git tag -a vX.Y.Z -m "Statecraft: Israel vX.Y.Z" && git push origin vX.Y.Z
+ gh release create vX.Y.Z unity/Builds/statecraft-israel-vX.Y.Z-web.zip --title "vX.Y.Z" --notes-file <(awk '/^## \[X.Y.Z\]/{f=1;next} /^## \[/{f=0} f' CHANGELOG.md)
+ ```
+
+ Paste the SHA-256 from step 5 into the release notes.
+7. **Check every published artefact:** download each uploaded zip (GitHub Releases, and itch.io once used) into an empty
+ folder, then run `unzip -Z1 <zip> | grep -E '^(LICENSE|NOTICE|THIRD-PARTY-NOTICES.md|OFL.txt)$'`. It must print four
+ lines for each zip.
+
+## Refreshing the README screenshots
+
+The README's screenshots are claims about the current build. Re-take them whenever the build looks different, and
+**always in the pull request that merges a visual change** (visual-v1 included), never as a follow-up:
+
+1. Build the web player (`docs/dev-setup.md`) and serve it. After visual-v1 has merged, capture with its
+ `uv run tools/web_check.py <build> --shots …` under its machine lock, so the capture does not disturb profiling.
+ Before that, capture by hand at 1640×920 in Chrome.
+2. Replace `docs/images/build-m3-map.jpg`, `build-m3-cabinet.jpg` and `build-m3-why.jpg` (or add `build-<milestone>-*`
+ and update the README to the new names). Each must show a non-sensitive moment: no unreviewed sensitive event card.
+3. Update the visible caption "Real screenshots from build X.Y.Z (Mn), YYYY-MM-DD." in `README.md`, and the
+ "Is this any good?" and "Roadmap" text the change made stale.
+4. Re-crop `docs/images/social-preview.jpg` (1280×640) from the new map shot. The owner re-uploads it under Settings →
+ General → Social preview. Never use concept art for the social preview.
+
+## Replacing the concept-art hero (planned)
+
+The hero at the top of the README is AI concept art of the target look (owner ruling, 2026-10-11). When a build reaches
+that look (the owner judges this at a visual-v1 or later art checkpoint, side by side with
+`promo/final/03-gameplay-1936.png`), a real screenshot takes its place:
+
+1. Capture the build at the promo pose, 2000 px wide, as `docs/images/hero-build.jpg`. Keep
+ `docs/images/hero-concept-1936.jpg`.
+2. In `README.md` and `README.he.md`, point the hero `<img>` at `hero-build.jpg` with alt text describing the real
+ build, and move the concept art down to a "Where it's going" line under the screenshots, still captioned as concept
+ art.
+3. In `ASSETS.yaml`, add a `docs/images/hero-build.jpg` row (`licence: CC-BY-4.0`, `status: verified`, source: the build
+ version and date).
+4. In `scripts/oss/tests/test_readme.py`, change `HERO` to `docs/images/hero-build.jpg`, and keep the assertion that
+ any concept-art image carries the concept-art caption.
+5. Add a CHANGELOG line, and land it as a normal pull request.
diff --git a/docs/m3-release.md b/docs/m3-release.md
index 99616e1d0..b9f967de1 100644
--- a/docs/m3-release.md
+++ b/docs/m3-release.md
@@ -108,7 +108,7 @@ Deferred to the start of M4, as a private Draft (owner ruling, 2026-10-10). The
owner's itch.io account and is never automated, and the build must pass the sensitivity gate above (`-shareable`).
1. Sign in at https://itch.io. Go to Dashboard, then **Create new project**.
2. Set the title to "Statecraft: Israel (M3 preview)", Kind of project to **HTML**, and Classification to Games.
-3. Under Uploads, upload `unity/Builds/statecraft-m3-web.zip` (made by `python3 tools/package_release.py`) and tick **This file will be played in the browser**.
+3. Under Uploads, upload the zip made by `bash scripts/oss/package_web.sh unity/Builds/Web-brotli unity/Builds/statecraft-m3-web.zip` (it puts the licence and attribution files inside, then runs `tools/package_release.py`; see `docs/RELEASING.md`) and tick **This file will be played in the browser**.
4. Embed options:
- Viewport **1280 × 720**. It fits a 1366×768 or 1440×900 laptop page without scrolling, and under the UI's
ScaleWithScreenSize (reference 1920×1080) it lays out exactly like 1920×1080; `UiLayoutTests` covers 1280×720.
diff --git a/scripts/oss/package_web.sh b/scripts/oss/package_web.sh
new file mode 100755
index 000000000..71af7d6be
--- /dev/null
+++ b/scripts/oss/package_web.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# Put the licence and attribution files INSIDE a WebGL build, have M3's sensitivity gate zip it
+# (tools/package_release.py: it refuses until every sensitive event is sensitivity-reviewed), then prove the notices
+# are in the zip by listing it. no_human shipped a bundle whose notices file pointed at a script that never copied
+# them; this script checks the artefact itself.
+# Usage: bash scripts/oss/package_web.sh unity/Builds/Web-brotli unity/Builds/statecraft-israel-vX.Y.Z-web.zip
+# PACKAGE_RELEASE overrides the zipping script (tests only).
+set -euo pipefail
+build="${1:?usage: package_web.sh BUILD_DIR ZIP_PATH}"
+zip_path="${2:?usage: package_web.sh BUILD_DIR ZIP_PATH}"
+root="$(cd "$(dirname "$0")/../.." && pwd)"
+packager="${PACKAGE_RELEASE:-$root/tools/package_release.py}"
+[ -f "$build/index.html" ] || { echo "not a WebGL build (no index.html): $build"; exit 1; }
+case "$zip_path" in /*) ;; *) zip_path="$PWD/$zip_path" ;; esac
+
+mkdir -p "$build/LICENSES"
+cp "$root/LICENSE" "$root/NOTICE" "$root/THIRD-PARTY-NOTICES.md" "$build/"
+cp "$root/LICENSES/"*.txt "$build/LICENSES/"
+cp "$root/unity/Assets/UI/Fonts/OFL.txt" "$build/OFL.txt"
+
+python3 "$packager" --build "$build" --zip "$zip_path"
+
+listing="$(unzip -Z1 "$zip_path")"
+for f in LICENSE NOTICE THIRD-PARTY-NOTICES.md OFL.txt LICENSES/CC-BY-4.0.txt LICENSES/CC-BY-SA-4.0.txt \
+ LICENSES/CC0-1.0.txt LICENSES/YamlDotNet-MIT.txt index.html; do
+ printf '%s\n' "$listing" | grep -qxF "$f" || { echo "MISSING in zip: $f"; rm -f "$zip_path"; exit 1; }
+done
+shasum -a 256 "$zip_path"
+echo "OK: notices inside $zip_path"
diff --git a/scripts/oss/release_gate.sh b/scripts/oss/release_gate.sh
new file mode 100755
index 000000000..68681a548
--- /dev/null
+++ b/scripts/oss/release_gate.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+# The release gate: run on main before every release tag (docs/RELEASING.md). Read-only: it changes nothing locally or
+# on GitHub. Exit 0 means the tip of main may be released; anything else names what is open.
+set -uo pipefail
+cd "$(dirname "$0")/../.."
+fail=0
+step() { echo; echo "== $1"; }
+
+step "on main, clean tree"
+[ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] || { echo "not on main"; fail=1; }
+[ -z "$(git status --porcelain --untracked-files=no)" ] || { echo "tracked changes present"; fail=1; }
+
+step "tip policy, release mode (open decisions D1-D12, owner-verify and unknown-licence rows refuse)"
+uv run scripts/oss/check_repo.py --release || fail=1
+
+step "policy tests"
+uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q || fail=1
+
+step "simulation and content tests"
+dotnet test sim/Statecraft.sln -c Release --nologo -v q || fail=1
+
+step "sensitivity gate on content/ (decision D11; Statecraft.Cli --release-gate)"
+dotnet run --project sim/Statecraft.Cli -v q -- --release-gate --content "$PWD/content" || fail=1
+
+step "tools tests"
+uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 pytest tools/tests -q || fail=1
+
+step "history scan of main (information; rows in docs/oss/history-accepted.tsv are accepted)"
+uv run scripts/oss/scan_history.py --ref main | tee /tmp/oss-release-scan.txt
+if ! grep -q ' 0 open secret-shape findings' /tmp/oss-release-scan.txt; then
+ echo "OPEN SECRET-SHAPE FINDING: rotate it at its provider (owner), then add the row to docs/oss/history-accepted.tsv"
+ fail=1
+fi
+
+echo
+if [ "$fail" -eq 0 ]; then echo "RELEASE GATE OK"; else echo "RELEASE GATE FAILED"; fi
+exit "$fail"
diff --git a/scripts/oss/tests/test_github_config.py b/scripts/oss/tests/test_github_config.py
index f0057d25c..e92bd2b02 100644
--- a/scripts/oss/tests/test_github_config.py
+++ b/scripts/oss/tests/test_github_config.py
@@ -109,3 +109,12 @@ def test_toolchain_is_pinned_and_main_pushes_are_not_cancelled():
assert 'UV_PYTHON: "3.12"' in text
assert "cancel-in-progress: ${{ github.event_name == 'pull_request' }}" in text
assert "ruleset-protect-main.json" not in text and "ruleset-main-review.json" in text
+
+
+def test_setup_uv_caches_on_the_files_that_carry_the_dependencies():
+ # No uv.lock exists (dependencies are inline), so the default glob matched nothing and CI warned.
+ uv_steps = [s for s in steps(ci()) if s.get("uses", "").startswith("astral-sh/setup-uv@")]
+ assert uv_steps
+ for s in uv_steps:
+ globs = s["with"]["cache-dependency-glob"].split()
+ assert globs == ["tools/**/*.py", "scripts/oss/**/*.py"], globs
diff --git a/scripts/oss/tests/test_policies.py b/scripts/oss/tests/test_policies.py
index 411612a6e..3884f010e 100644
--- a/scripts/oss/tests/test_policies.py
+++ b/scripts/oss/tests/test_policies.py
@@ -118,7 +118,8 @@ def test_docs_describe_only_what_is_live_today():
def test_contributing_uses_the_check_that_passes_today():
# Review I6: the full check_repo run fails until Task 14; CI's own command is what a contributor can run.
c = read("CONTRIBUTING.md")
- assert "uv run scripts/oss/check_repo.py --only secrets,emails,home-paths,sizes,symlinks" in c
+ # Task 14 landed the last required files, so CI and CONTRIBUTING both run the full check now.
+ assert "`uv run scripts/oss/check_repo.py` (the command CI runs)" in c and "check_repo.py --only" not in c
def test_untrusted_review_profile_restores_with_network_then_runs_without():
diff --git a/scripts/oss/tests/test_release.py b/scripts/oss/tests/test_release.py
new file mode 100644
index 000000000..540b6aa68
--- /dev/null
+++ b/scripts/oss/tests/test_release.py
@@ -0,0 +1,64 @@
+import os
+import re
+import subprocess
+import zipfile
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[3]
+NOTICES = ["LICENSE", "NOTICE", "THIRD-PARTY-NOTICES.md", "LICENSES/CC-BY-4.0.txt", "LICENSES/CC-BY-SA-4.0.txt",
+ "LICENSES/CC0-1.0.txt", "LICENSES/YamlDotNet-MIT.txt", "OFL.txt"]
+# Stands in for tools/package_release.py (which needs dotnet and real content): zips the folder, index.html at the root.
+STUB = """import argparse, zipfile
+from pathlib import Path
+a = argparse.ArgumentParser(); a.add_argument("--build"); a.add_argument("--zip"); a = a.parse_args()
+b = Path(a.build)
+with zipfile.ZipFile(a.zip, "w") as z:
+ for f in sorted(p for p in b.rglob("*") if p.is_file()):
+ z.write(f, f.relative_to(b).as_posix())
+print("PACKAGED", a.zip)
+"""
+
+
+def run(tmp_path, build, out, stub=STUB):
+ s = tmp_path / "stub.py"
+ s.write_text(stub)
+ return subprocess.run(["bash", str(ROOT / "scripts/oss/package_web.sh"), str(build), str(out)], cwd=ROOT,
+ capture_output=True, text=True, env=dict(os.environ, PACKAGE_RELEASE=str(s)))
+
+
+def fake_build(tmp_path):
+ build = tmp_path / "Web-brotli"
+ (build / "Build").mkdir(parents=True)
+ (build / "index.html").write_text("<html></html>")
+ (build / "Build" / "x.data.br").write_bytes(b"\x00")
+ return build
+
+
+def test_the_gate_zip_carries_every_notice(tmp_path):
+ out = tmp_path / "game.zip"
+ r = run(tmp_path, fake_build(tmp_path), out)
+ assert r.returncode == 0, r.stdout + r.stderr
+ names = set(zipfile.ZipFile(out).namelist())
+ assert "index.html" in names and "Build/x.data.br" in names
+ for n in NOTICES:
+ assert n in names, n
+
+
+def test_a_refusing_gate_stops_the_package(tmp_path):
+ out = tmp_path / "game.zip"
+ r = run(tmp_path, fake_build(tmp_path), out, stub="import sys\nprint('PACKAGE REFUSED: review')\nsys.exit(1)\n")
+ assert r.returncode != 0 and "PACKAGE REFUSED" in r.stdout and not out.exists()
+
+
+def test_package_refuses_a_missing_build(tmp_path):
+ r = run(tmp_path, tmp_path / "nope", tmp_path / "z.zip")
+ assert r.returncode != 0 and not (tmp_path / "z.zip").exists()
+
+
+def test_versions_agree():
+ sim = re.search(r'Version = "([^"]+)"', (ROOT / "sim/Statecraft.Sim/SimInfo.cs").read_text()).group(1)
+ unity = re.search(r"bundleVersion: (\S+)", (ROOT / "unity/ProjectSettings/ProjectSettings.asset").read_text()).group(1)
+ assert sim == unity
+ released = re.findall(r"^## \[(\d+\.\d+\.\d+)\]", (ROOT / "CHANGELOG.md").read_text(), re.M)
+ if released:
+ assert released[0] == sim