OXYGENHUB
◆ main oxygenflow / scripts / dist.sh
2.0 KiB · Bourne Again Shell (bash) · executable · last changed Windows runner: free disk in claims; dist builds flow-windows-x86_64.exe 9 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; flow-windows-x86_64.exe (the WASM tier only);
7
# and SHA256SUMS of them.
8
#
9
#   scripts/dist.sh [VERSION]    (default: the package version)
10
#   ONLY=x86_64 scripts/dist.sh  builds one architecture (a glob)
11
#
12
# Needs: rustup targets aarch64-unknown-linux-gnu and
13
# riscv64gc-unknown-linux-gnu and x86_64-pc-windows-gnu; cargo-zigbuild
14
# and zig on PATH; the MinGW-w64 gcc.
15
set -euo pipefail
16
17
cd "$(dirname "$0")/.."
18
VERSION="${1:-$(cargo pkgid -p flow | sed 's/.*[#@]//')}"
19
VERSION="${VERSION#v}"
20
OUT="${DIST_FLAT:-target/dist-flat}"
21
rm -rf "$OUT" && mkdir -p "$OUT"
22
export PATH="$HOME/.local/opt/zig:$PATH"
23
# Stripped, with no debug info: about a tenth of the size.
24
export CARGO_PROFILE_RELEASE_DEBUG=0 CARGO_PROFILE_RELEASE_STRIP=true CARGO_INCREMENTAL=0
25
# The version the binary reports, which the hub compares with its releases.
26
export OXY_BUILD="v$VERSION"
27
28
for p in "x86_64-unknown-linux-gnu|x86_64" "aarch64-unknown-linux-gnu|aarch64" "riscv64gc-unknown-linux-gnu|riscv64"; do
29
  IFS='|' read -r triple arch <<<"$p"
30
  if [ -n "${ONLY:-}" ] && [[ "$arch" != $ONLY ]]; then continue; fi
31
  echo "== linux-$arch ($triple)"
32
  cargo zigbuild -q --release --locked --target "$triple.2.28" -p flow --bin flow
33
  install -m 0755 "target/$triple/release/flow" "$OUT/flow-linux-$arch"
34
done
35
# Windows (oxygenflow#83): the WASM tier only, with the MinGW-w64 toolchain.
36
if [ -z "${ONLY:-}" ] || [[ windows-x86_64 == $ONLY ]]; then
37
  echo "== windows-x86_64 (x86_64-pc-windows-gnu)"
38
  cargo build -q --release --locked --target x86_64-pc-windows-gnu -p flow --bin flow
39
  install -m 0755 target/x86_64-pc-windows-gnu/release/flow.exe "$OUT/flow-windows-x86_64.exe"
40
fi
41
(cd "$OUT" && sha256sum flow-* > SHA256SUMS && cat SHA256SUMS)