#!/usr/bin/env bash # verify-version-consistency.sh — Block A of preflight. # # v0.1.0 ships before the first repo.json release manifest exists, so this # script is tolerant when the file is missing - the csproj is # the single source of truth at the bootstrap stage. Once repo.json # lands (probably v0.1.1 or v0.2.0), the missing-file path turns into a # full csproj <-> repo.json AssemblyVersion + TestingAssemblyVersion + # DownloadLink* tag check, matching the HellionChat preflight. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" CSPROJ="$ROOT/Anvil/Anvil.csproj" REPO_JSON="$ROOT/repo.json" fail() { echo "verify-version-consistency: FAIL — $1" >&2; exit 1; } ok() { echo "verify-version-consistency: OK — $1"; } CSPROJ_VER="$(grep -oE '[^<]+' "$CSPROJ" | head -1 | sed -E 's/<[^>]+>//g')" [ -n "$CSPROJ_VER" ] || fail "$CSPROJ has no element" if [ ! -f "$REPO_JSON" ]; then ok "csproj=$CSPROJ_VER (repo.json absent - bootstrap stage, skipping cross-check)" exit 0 fi EXPECTED_4DIGIT="${CSPROJ_VER}.0" REPO_VER="$(jq -r '.[0].AssemblyVersion' "$REPO_JSON")" [ "$REPO_VER" = "$EXPECTED_4DIGIT" ] \ || fail "csproj=$CSPROJ_VER expects repo.json AssemblyVersion=$EXPECTED_4DIGIT but got $REPO_VER. Fix: align in $REPO_JSON." TEST_VER="$(jq -r '.[0].TestingAssemblyVersion' "$REPO_JSON")" [ "$TEST_VER" = "$EXPECTED_4DIGIT" ] \ || fail "TestingAssemblyVersion=$TEST_VER must match $EXPECTED_4DIGIT. Fix: align in $REPO_JSON." TAG="v$CSPROJ_VER" for KEY in DownloadLinkInstall DownloadLinkUpdate DownloadLinkTesting; do URL="$(jq -r ".[0].$KEY" "$REPO_JSON")" case "$URL" in *"/$TAG/"*) ;; *) fail "$KEY=$URL does not contain tag $TAG. Fix: update $REPO_JSON $KEY to releases/download/$TAG/latest.zip." ;; esac done ok "csproj=$CSPROJ_VER, repo.json=$EXPECTED_4DIGIT, tag $TAG present in DownloadLinks"