#!/usr/bin/env bash # Regenerates src/game/build_info.json from the current git state. # Invoke before an export so the About screen shows the correct commit. # # Available two ways: # * Directly: `./scripts/run/build-info.sh` # * Via runner: `./run build:info` (calls cmd_build_info below) # # Previously this file was top-level executable code — sourcing it via # the runner's `for _script in scripts/run/*.sh; source "$_script"` loop # regenerated build_info.json on EVERY `./run ` invocation, # including quick ones like `./run lint:gd`. Wrapping in a function makes # the write lazy: only runs when explicitly called by a build/export cmd. # Regenerate src/game/build_info.json. Idempotent, side-effect-free at source time. cmd_build_info() { local repo_root="${REPO_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}" local commit build_date version_base version commit="$(git -C "$repo_root" rev-parse --short=12 HEAD 2>/dev/null || echo unknown)" build_date="$(date -u +%Y-%m-%dT%H:%M:%SZ)" version_base="$(awk -F'"' '/^config\/version=/ {print $2}' "$repo_root/src/game/project.godot" 2>/dev/null || echo 0.0.0)" version="${version_base}-ea" cat > "$repo_root/src/game/build_info.json" <