#!/usr/bin/env bash # Builds the CLI for a target platform and packages it as expected by the updater: # acaua--.tar.gz alongside a .sha256 checksum file. # # scripts/package-cli.sh v1.0.3 linux-x86_64 x86_64-unknown-linux-gnu # # Supported platforms: linux-x86_64 and linux-aarch64. When cross-compiling # from a non-x86_64 host, uses gcc-x86-64-linux-gnu. Writes the archives to the # repository root and prints their filenames. set -euo pipefail cd "$(dirname "$0")/.." tag=${1:?usage: package-cli.sh } platform=${2:?usage: package-cli.sh } target=${3:?usage: package-cli.sh } case "$target" in x86_64-unknown-linux-gnu) if [ "$(uname -m)" != x86_64 ]; then export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc export CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc fi ;; esac rustup target add "$target" >/dev/null 2>&1 || true cargo build --release --locked -p acaua-cli --target "$target" name="acaua-${tag}-${platform}" rm -rf "$name"; mkdir "$name" cp "${CARGO_TARGET_DIR:-target}/${target}/release/acaua" "$name/" cp README.md LICENSE-MIT LICENSE-APACHE "$name/" tar czf "$name.tar.gz" "$name" asset="$name.tar.gz" rm -rf "$name" sha256sum "$asset" > "$asset.sha256" echo "$asset" echo "$asset.sha256"