#!/usr/bin/env bash
# release-home-map — ship a starter map from YOUR HOME (docs/home-world-design.md §6).
#
# tools/release-home-map.sh [map_id] # default: map_test
#
# A deliberate dev step, run when you mean to release a new starter -- never CI.
# Needs the keet-daemon running (scripts/dev-run.sh, or dev-run.sh --daemon-only).
# Reads your home room read-only, writes res://home/<map_id>.home.json plus the
# content it uses under home/content/, and prints the git diff. Review, commit,
# `git push pear master` -- the push is the release.
set -uo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
. "$REPO/scripts/engine.sh"
DAEMON_TAG=release-home-map
. "$REPO/scripts/daemon.sh"
map="${1:-map_test}"
[ -x "$GODOT" ] || { echo "release-home-map: engine missing at $GODOT" >&2; exit 1; }
# The daemon is NOT started here: releasing reads YOUR home, which is the daemon
# you play with. Starting one on the side would be a second process on the same
# identity storage.
if [ -z "${HYPERTPS_DAEMON_TCP:-}" ] && ! _daemon_alive; then
echo "release-home-map: no keet-daemon on $SOCK — start one (scripts/dev-run.sh --daemon-only)" >&2
exit 1
fi
# Stamp the starter with the code it was released from (a dev tree has no
# version.txt), the same way dev-run.sh stamps a run.
if [ -z "${HYPER_TPS_BUILD:-}" ]; then
_head="$(git -C "$REPO" rev-parse --short HEAD 2>/dev/null || echo nogit)"
git -C "$REPO" diff --quiet 2>/dev/null || _head="${_head}-dirty"
export HYPER_TPS_BUILD="dev-${_head}"
fi
"$GODOT" --headless --path "$REPO" --script res://tools/release_home_map.gd -- "$map" "${@:2}"
rc=$?
[ $rc -eq 0 ] || exit $rc
git -C "$REPO" status --short -- home/
git -C "$REPO" diff --stat -- home/