#!/bin/bash
#
# build.sh — invoked automatically by release.sh before `adompkg publish`.
#
# Builds the release binary and stages it into bin/ so the published tarball
# always ships a REAL binary. (The repo intentionally does NOT commit the
# compiled binary — see .gitignore — so without this step a publish would ship
# an empty/missing bin/adom-footprint and `adompkg install` would be broken.
# This is exactly the regression that shipped a 91-byte stub in earlier tags.)
#
set -euo pipefail
DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$DIR"

cargo build --release
cargo test --release            # keep the golden + placement tests green on every publish

mkdir -p bin
cp target/release/adom-footprint bin/adom-footprint
chmod 0755 bin/adom-footprint
echo "build.sh: staged bin/adom-footprint -> $(./bin/adom-footprint --version)"