#!/usr/bin/env bash
# Sync the single source of truth (/VERSION) into the Godot client's project.godot
# (application/config/version). Run after bumping /VERSION.
set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
version="$(tr -d '[:space:]' < "$root/VERSION")"
proj="$root/client/project.godot"
if grep -q '^config/version=' "$proj"; then
  sed -i "s|^config/version=.*|config/version=\"$version\"|" "$proj"
else
  sed -i "s|^\(config/name=.*\)|\1\nconfig/version=\"$version\"|" "$proj"
fi
echo "synced client config/version = \"$version\""
