hex/scripts/release-homebrew.sh
Dax Raad c5338422a0 ci(release): split building from signing and publishing, like OpenCode
Build jobs (Linux, Windows x64/ARM64, macOS, Windows installers, AUR and Homebrew staging) run repository code with no environment, secret, or id-token and produce unsigned files. Sign and publish jobs run in the release environment, check out only .github/release/, and run only those scripts and SHA-pinned actions on artifacts treated as data: macOS Developer ID signing, notarization, and stapling (from APPLE_SIGNING_CERTIFICATE, APPLE_NOTARY_KEY, and the APPLE_NOTARY_KEY_ID/ISSUER_ID variables), Azure Authenticode, the release service, the GitHub release, and the AUR and Homebrew pushes. Every artifact carries a SHA256SUMS whose digest its job reports; every job that downloads it checks that digest. Signed macOS builds are verified and launched in a job without secrets. macos-signed.yml is gone (a check run covers it); the site deploy is no longer part of Release.
2026-10-27 17:02:44 -04:00

43 lines
1.4 KiB
Shell
Executable file

#!/bin/sh
# Renders the Homebrew cask anomalyco/tap/hex (anomalyco/homebrew-tap,
# Casks/hex.rb) from packaging/homebrew/hex.rb, without secrets. The Release
# workflow's Homebrew job pushes it with .github/release/push-homebrew.sh.
#
# release-homebrew.sh render <version> <dmg-url> <sha256> <out>
#
# The DMG URL is the release service's macos-arm64-dmg file.
set -eu
root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
usage() {
echo "Usage: $0 render <version> <dmg-url> <sha256> <out>" >&2
exit 1
}
case "${1:-}" in
render)
[ $# -eq 5 ] || usage
version=$2 url=$3 sha256=$4 out=$5
printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-(beta|dev)\.[0-9]+)?$'
printf '%s\n' "$sha256" | grep -Eq '^[0-9a-f]{64}$'
printf '%s\n' "$url" | grep -Eq '^https://[A-Za-z0-9./_-]+\.dmg$'
case "$url" in
*"$version"*) ;;
*)
echo "The DMG URL must name version $version." >&2
exit 1
;;
esac
# Homebrew wants the URL to interpolate the version.
# shellcheck disable=SC2016
versioned=$(printf '%s' "$url" | sed "s|$(printf '%s' "$version" | sed 's/[.]/\\./g')|#{version}|g")
sed -e "s|@VERSION@|$version|" -e "s|@SHA256@|$sha256|" -e "s|@URL@|$versioned|" \
"$root/packaging/homebrew/hex.rb" > "$out"
if grep -q '@[A-Z0-9_]*@' "$out"; then
echo "The cask has an unfilled placeholder." >&2
exit 1
fi
echo "$out"
;;
*) usage ;;
esac