main gen-brew.sh
Eric Bower  ·  2026-06-13
 1#!/usr/bin/env bash
 2set -euo pipefail
 3
 4VERSION="${1:?usage: generate-brew.sh <version>}"
 5DIST="${2:-zig-out/dist}"
 6
 7if [[ ! -f brew.tmpl ]]; then
 8  echo "error: brew.tmpl not found" >&2
 9  exit 1
10fi
11
12shasum() {
13  local platform="$1"
14  local file="${DIST}/zmx-${VERSION}-${platform}.tar.gz.sha256"
15  if [[ ! -f "$file" ]]; then
16    echo "error: missing $file" >&2
17    exit 1
18  fi
19  cut -d ' ' -f1 < "$file"
20}
21
22sed \
23  -e "s/{ver}/${VERSION}/g" \
24  -e "s/{shasum_macos-aarch64}/$(shasum macos-aarch64)/" \
25  -e "s/{shasum_macos-x86_64}/$(shasum macos-x86_64)/" \
26  -e "s/{shasum_linux-aarch64}/$(shasum linux-aarch64)/" \
27  -e "s/{shasum_linux-x86_64}/$(shasum linux-x86_64)/" \
28  brew.tmpl