omnigraph/scripts/update-homebrew-formula.sh
Ragnor Comerford d50d94f89b
ci: add linux-arm64 (aarch64) prebuilt release target (#316)
* ci: add linux-arm64 (aarch64) prebuilt release target

Build an omnigraph-linux-arm64 archive in both the tagged-release and
edge-release matrices on the ubuntu-24.04-arm runner, and teach the
install script to map Linux/aarch64 to the new asset. Update the install
and CI docs to list the new platform.

Previously aarch64 Linux hit the install-script arch guard
("no prebuilt binary is available for Linux/aarch64") and could only
build from source; it is now a first-class prebuilt target.

* ci: emit a linux-arm64 bottle in the Homebrew formula

The formula generator only resolved macos-arm64 and linux-x86_64 and
emitted `on_linux { on_intel }`, so `brew install` on Linux/aarch64 had
no URL/sha and failed even though the release now ships an
omnigraph-linux-arm64 archive. Resolve that asset's digest and add an
`on_arm` block under `on_linux` so the documented Homebrew path matches
the new prebuilt target.
2026-06-29 22:55:44 +02:00

106 lines
2.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage: update-homebrew-formula.sh <tag> [formula_path]
Environment:
REPO_SLUG GitHub repository that owns the Omnigraph release
default: ModernRelay/omnigraph
EOF
}
need_cmd() {
command -v "$1" >/dev/null 2>&1 || {
printf 'error: missing required command: %s\n' "$1" >&2
exit 1
}
}
asset_digest() {
local release_json="$1"
local asset_name="$2"
jq -r --arg name "$asset_name" '
.assets[]
| select(.name == $name)
| (.digest // "")
| sub("^sha256:"; "")
' <<<"$release_json"
}
TAG="${1:-}"
FORMULA_PATH="${2:-Formula/omnigraph.rb}"
REPO_SLUG="${REPO_SLUG:-ModernRelay/omnigraph}"
if [[ -z "$TAG" ]]; then
usage
exit 1
fi
need_cmd gh
need_cmd jq
VERSION="${TAG#v}"
RELEASE_JSON="$(gh release view "$TAG" --repo "$REPO_SLUG" --json assets)"
MACOS_ARM_URL="https://github.com/${REPO_SLUG}/releases/download/${TAG}/omnigraph-macos-arm64.tar.gz"
LINUX_X86_URL="https://github.com/${REPO_SLUG}/releases/download/${TAG}/omnigraph-linux-x86_64.tar.gz"
LINUX_ARM_URL="https://github.com/${REPO_SLUG}/releases/download/${TAG}/omnigraph-linux-arm64.tar.gz"
MACOS_ARM_SHA="$(asset_digest "$RELEASE_JSON" "omnigraph-macos-arm64.tar.gz")"
LINUX_X86_SHA="$(asset_digest "$RELEASE_JSON" "omnigraph-linux-x86_64.tar.gz")"
LINUX_ARM_SHA="$(asset_digest "$RELEASE_JSON" "omnigraph-linux-arm64.tar.gz")"
for value in "$MACOS_ARM_SHA" "$LINUX_X86_SHA" "$LINUX_ARM_SHA"; do
if [[ -z "$value" ]]; then
printf 'error: failed to resolve one or more release asset digests for %s\n' "$TAG" >&2
exit 1
fi
done
mkdir -p "$(dirname "$FORMULA_PATH")"
cat >"$FORMULA_PATH" <<EOF
class Omnigraph < Formula
desc "Typed property graph database with Git-style workflows"
homepage "https://github.com/${REPO_SLUG}"
version "${VERSION}"
license "MIT"
head "https://github.com/${REPO_SLUG}.git", branch: "main"
livecheck do
url :stable
regex(/^v?(\\d+(?:\\.\\d+)+)$/i)
end
on_macos do
depends_on arch: :arm64
on_arm do
url "${MACOS_ARM_URL}"
sha256 "${MACOS_ARM_SHA}"
end
end
on_linux do
on_intel do
url "${LINUX_X86_URL}"
sha256 "${LINUX_X86_SHA}"
end
on_arm do
url "${LINUX_ARM_URL}"
sha256 "${LINUX_ARM_SHA}"
end
end
def install
bin.install "omnigraph", "omnigraph-server"
end
test do
assert_match "omnigraph ", shell_output("#{bin}/omnigraph version")
assert_match "HTTP server for the Omnigraph graph database", shell_output("#{bin}/omnigraph-server --help")
end
end
EOF