#!/usr/bin/env bash # Builds the CLI for a target platform and packages it as: # guara--.tar.gz alongside a .sha256 checksum file. # # scripts/package-cli.sh v1.3.2 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 } if [ "$target" = x86_64-unknown-linux-gnu ] && [ "$(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 rustup target add "$target" >/dev/null 2>&1 || true cargo build --release --locked -p guara-cli --target "$target" name="guara-${tag}-${platform}" rm -rf "$name"; mkdir "$name" cp "${CARGO_TARGET_DIR:-target}/${target}/release/guara" "$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"