hex/scripts/release-homebrew.sh
Dax 52e247fdf8
Release files publish as plain names: hex, Hex.dmg, Hex.zip, hex.exe, HexSetup.exe (#234)
The release service stores each file at files/<sha256>/<name> and serves it as an attachment named <name>, so names need no version or target: linux-x64 is hex, macos-arm64-dmg Hex.dmg, macos-arm64 Hex.zip, windows-x64/arm64 hex.exe, and the Windows installers HexSetup.exe (the service's names allow no spaces). Targets reference {file, sha256}, so the two Windows architectures may share a name. Builds and the GitHub release mirror keep versioned names; release-service.sh maps them. The updater, installers, and AUR PKGBUILD (hex-<pkgver>-linux-x64::<url>) take the URL from the manifest; the AUR and Homebrew renderers accept the new URLs, and the cask URL no longer interpolates the version.
2026-10-27 19:40:53 -04:00

34 lines
1.2 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://anoma\.ly/release/hex/files/[0-9a-f]{64}/Hex\.dmg$'
# The file is Hex.dmg under its sha256, so the URL names no version.
sed -e "s|@VERSION@|$version|" -e "s|@SHA256@|$sha256|" -e "s|@URL@|$url|" \
"$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