#!/usr/bin/env bash # Build the runner, `flow`, for every Linux machine a runner runs on # (glibc 2.28 and later), as release assets runners update themselves from # (docs/jetstream.md ยง8.2, oxygenhub#322): target/dist-flat/flow-linux-ARCH, # named by the architecture a runner reports (x86_64, aarch64, riscv64), # plain stripped binaries, and SHA256SUMS of them. # # scripts/dist.sh [VERSION] (default: the package version) # ONLY=x86_64 scripts/dist.sh builds one architecture (a glob) # # Needs: rustup targets aarch64-unknown-linux-gnu and # riscv64gc-unknown-linux-gnu; cargo-zigbuild and zig on PATH. set -euo pipefail cd "$(dirname "$0")/.." VERSION="${1:-$(cargo pkgid -p flow | sed 's/.*[#@]//')}" VERSION="${VERSION#v}" OUT="${DIST_FLAT:-target/dist-flat}" rm -rf "$OUT" && mkdir -p "$OUT" export PATH="$HOME/.local/opt/zig:$PATH" # Stripped, with no debug info: about a tenth of the size. export CARGO_PROFILE_RELEASE_DEBUG=0 CARGO_PROFILE_RELEASE_STRIP=true CARGO_INCREMENTAL=0 # The version the binary reports, which the hub compares with its releases. export OXY_BUILD="v$VERSION" for p in "x86_64-unknown-linux-gnu|x86_64" "aarch64-unknown-linux-gnu|aarch64" "riscv64gc-unknown-linux-gnu|riscv64"; do IFS='|' read -r triple arch <<<"$p" if [ -n "${ONLY:-}" ] && [[ "$arch" != $ONLY ]]; then continue; fi echo "== linux-$arch ($triple)" cargo zigbuild -q --release --locked --target "$triple.2.28" -p flow --bin flow install -m 0755 "target/$triple/release/flow" "$OUT/flow-linux-$arch" done (cd "$OUT" && sha256sum flow-linux-* > SHA256SUMS && cat SHA256SUMS)