#!/usr/bin/env bash
# chip-thumbnailer build script. Builds the release binary; doesn't
# upload to the wiki — that's a separate `adom-wiki asset upload`
# step gated on user approval per the wiki-publish rule.
set -euo pipefail
cd "$(dirname "$0")"

VERSION=$(cat VERSION | tr -d '[:space:]')
echo "[chip-thumbnailer] Building v${VERSION}..."
cargo build --release
echo "[adom-chip-thumbnailer] Built target/release/adom-chip-thumbnailer ($(stat -c%s target/release/adom-chip-thumbnailer 2>/dev/null || stat -f%z target/release/adom-chip-thumbnailer) bytes)"

echo
echo "Next, to ship:"
echo "  1. Upload SKILL.md to wiki:"
echo "     adom-wiki asset upload app/chip-thumbnailer --asset-type file --file SKILL.md \\"
echo "       --caption 'Skill content fetched at install time' \\"
echo "       --changelog 'v${VERSION}'"
echo "  2. Upload binary:"
echo "     adom-wiki asset upload app/chip-thumbnailer --asset-type docker-binary \\"
echo "       --file target/release/adom-chip-thumbnailer \\"
echo "       --caption 'v${VERSION} binary for adom docker containers' \\"
echo "       --changelog 'v${VERSION}'"
echo "  3. Bump page version:"
echo "     adom-wiki page publish app/chip-thumbnailer ... --version ${VERSION}"
