#!/bin/sh
# Runs inside the repomon linux-build-aarch64 job (see
# .repomon/release.toml) -- the other of two jobs that split the Linux
# builds by architecture across separate machines. Builds
# aarch64-unknown-linux-gnu via `cross` (matching the old GitHub Actions
# release.yml's `use-cross: true` entry for this target exactly) and
# packages it the same way linux-build-x86_64.sh does.
#
# `cross` is bootstrapped here since this script runs standalone via
# repomon, not through `cargo rake`. Requires Docker already installed on
# this machine.
set -eu

command -v cross >/dev/null 2>&1 || cargo install cross --force --locked

t=aarch64-unknown-linux-gnu
version=$(git describe --tags --exact-match | sed 's/^v//')

cross 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
