#!/bin/sh
# Runs inside the repomon macos-build job (see .repomon/release.toml).
# Builds both aarch64-apple-darwin (native) and x86_64-apple-darwin
# (cross-compiled -- Apple Silicon's toolchain supports this natively via
# rustup, no Docker/cross needed) from one runner, preserving the old
# (GitHub Actions) release.yml's 2-target macOS matrix, and packages each
# exactly like it did: a single-binary tar.gz per target.
set -eu

version=$(git describe --tags --exact-match | sed 's/^v//')

for t in aarch64-apple-darwin x86_64-apple-darwin; do
    rustup target add "$t" >/dev/null 2>&1 || true
    cargo build --release --locked --target "$t"

    cp "target/$t/release/cargo-matrix" ./cargo-matrix
    tar czf "cargo-matrix-$t-v$version.tar.gz" cargo-matrix
    rm -f cargo-matrix
done
