OXYGENHUB
# 3554afefb6aa oxygenflow / scripts / dist.sh
1.6 KiB · Bourne Again Shell (bash) · executable · last changed dist: runner builds for releases 10 days ago source blame history raw
1
#!/usr/bin/env bash
2
# Build the runner, `flow`, for every Linux machine a runner runs on
3
# (glibc 2.28 and later), as release assets runners update themselves from
4
# (docs/jetstream.md §8.2, oxygenhub#322): target/dist-flat/flow-linux-ARCH,
5
# named by the architecture a runner reports (x86_64, aarch64, riscv64),
6
# plain stripped binaries, and SHA256SUMS of them.
7
#
8
#   scripts/dist.sh [VERSION]    (default: the package version)
9
#   ONLY=x86_64 scripts/dist.sh  builds one architecture (a glob)
10
#
11
# Needs: rustup targets aarch64-unknown-linux-gnu and
12
# riscv64gc-unknown-linux-gnu; cargo-zigbuild and zig on PATH.
13
set -euo pipefail
14
15
cd "$(dirname "$0")/.."
16
VERSION="${1:-$(cargo pkgid -p flow | sed 's/.*[#@]//')}"
17
VERSION="${VERSION#v}"
18
OUT="${DIST_FLAT:-target/dist-flat}"
19
rm -rf "$OUT" && mkdir -p "$OUT"
20
export PATH="$HOME/.local/opt/zig:$PATH"
21
# Stripped, with no debug info: about a tenth of the size.
22
export CARGO_PROFILE_RELEASE_DEBUG=0 CARGO_PROFILE_RELEASE_STRIP=true CARGO_INCREMENTAL=0
23
# The version the binary reports, which the hub compares with its releases.
24
export OXY_BUILD="v$VERSION"
25
26
for p in "x86_64-unknown-linux-gnu|x86_64" "aarch64-unknown-linux-gnu|aarch64" "riscv64gc-unknown-linux-gnu|riscv64"; do
27
  IFS='|' read -r triple arch <<<"$p"
28
  if [ -n "${ONLY:-}" ] && [[ "$arch" != $ONLY ]]; then continue; fi
29
  echo "== linux-$arch ($triple)"
30
  cargo zigbuild -q --release --locked --target "$triple.2.28" -p flow --bin flow
31
  install -m 0755 "target/$triple/release/flow" "$OUT/flow-linux-$arch"
32
done
33
(cd "$OUT" && sha256sum flow-linux-* > SHA256SUMS && cat SHA256SUMS)