open-standards/wai/wai-quantum-cli/release/package.sh
Transaction Science 06941cf250 wai-quantum-cli: release builds for macOS, Linux and Windows, with a Homebrew formula and a Scoop manifest
A tag wai-quantum-cli-v<version> (the crate's version, checked) builds the
wai-quantum binary on the project's own runners and attaches each archive, with its
SHA-256, to the forge release of that tag:
- macOS: aarch64-apple-darwin and x86_64-apple-darwin, with the GPU state vector;
- Linux: x86_64- and aarch64-unknown-linux-musl, static, checked as such, so any
  distribution runs them;
- Windows: x86_64-pc-windows-msvc, as a zip.
Each binary runs once before it is packaged (--version, and a did:key from
`key --demo-key`). A last job writes the Homebrew formula and the Scoop manifest
from the attached SHA-256 files, leaving out a platform whose build attached nothing,
and attaches them too.

release/package.sh makes the archive (the binary, README and LICENSE; the same bytes
for the same inputs where GNU tar is there) and its .sha256. release/publish.sh
creates the release if no build has yet, replaces an asset of the same name, and
uploads over the private network, not the public tunnel. release/formulae.py writes
the formula and the manifest. The README says how to install it each way.

Checked here: package.sh on the macOS binary (the archive verifies against its
.sha256, unpacks, and runs); formulae.py against a stand-in release with three of the
five platforms attached (the formula holds those three, Ruby reads it, and the
manifest is the Windows one). The workflow itself runs on its first tag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 66fd49edc0)
2026-10-20 17:34:17 -04:00

30 lines
1.4 KiB
Shell
Executable file

#!/usr/bin/env bash
# Package a built wai-quantum binary for release:
#
# bash release/package.sh <binary> <version> <triple> <out-dir>
#
# Writes <out-dir>/wai-quantum-<version>-<triple>.tar.gz holding wai-quantum (or
# wai-quantum.exe), README.md and LICENSE, and beside it the archive's SHA-256 in
# <archive>.sha256 in the form `shasum -a 256 -c` reads. Run from wai/wai-quantum-cli.
set -euo pipefail
if [ $# -ne 4 ]; then
echo "usage: bash release/package.sh <binary> <version> <triple> <out-dir>" >&2
exit 2
fi
BIN="$1"; VERSION="$2"; TRIPLE="$3"; OUT="$4"
NAME="wai-quantum-$VERSION-$TRIPLE"
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
mkdir -p "$STAGE/$NAME" "$OUT"
case "$BIN" in
*.exe) cp "$BIN" "$STAGE/$NAME/wai-quantum.exe" ;;
*) cp "$BIN" "$STAGE/$NAME/wai-quantum"; chmod 755 "$STAGE/$NAME/wai-quantum" ;;
esac
cp README.md "$STAGE/$NAME/README.md"
cp ../LICENSE "$STAGE/$NAME/LICENSE"
# The same bytes for the same inputs: sorted names, fixed owner and times.
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime='2026-01-01 00:00Z' -C "$STAGE" -cf - "$NAME" 2>/dev/null \
| gzip -n -9 > "$OUT/$NAME.tar.gz" \
|| tar -C "$STAGE" -cf - "$NAME" | gzip -n -9 > "$OUT/$NAME.tar.gz"
( cd "$OUT" && { command -v sha256sum >/dev/null && sha256sum "$NAME.tar.gz" || shasum -a 256 "$NAME.tar.gz"; } > "$NAME.tar.gz.sha256" )
echo "packaged $OUT/$NAME.tar.gz ($(cut -d' ' -f1 "$OUT/$NAME.tar.gz.sha256"))"