#!/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; flow-windows-x86_64.exe (the WASM tier only); # 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 and x86_64-pc-windows-gnu; cargo-zigbuild # and zig on PATH; the MinGW-w64 gcc. 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 # Windows (oxygenflow#83): the WASM tier only, with the MinGW-w64 toolchain. if [ -z "${ONLY:-}" ] || [[ windows-x86_64 == $ONLY ]]; then echo "== windows-x86_64 (x86_64-pc-windows-gnu)" cargo build -q --release --locked --target x86_64-pc-windows-gnu -p flow --bin flow install -m 0755 target/x86_64-pc-windows-gnu/release/flow.exe "$OUT/flow-windows-x86_64.exe" fi (cd "$OUT" && sha256sum flow-* > SHA256SUMS && cat SHA256SUMS)