Skip to content

Commit fdea7bf

Browse files
committed
Add homebrew tap update script
1 parent 3dc46f7 commit fdea7bf

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

scripts/update-tap.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# Update the homebrew tap formula (ioma8/homebrew-tap) to a released fishez version.
3+
# Usage: ./scripts/update-tap.sh [version] (default: 0.4.0)
4+
# Prereq: the GitHub release v<version> with binaries must already exist.
5+
6+
set -euo pipefail
7+
8+
VERSION=${1:-0.4.0}
9+
TAP_REPO="ioma8/homebrew-tap"
10+
ASSETS=(fishez-macos-aarch64 fishez-macos-x86_64 fishez-linux-aarch64 fishez-linux-x86_64)
11+
12+
# Fetch authoritative sha256 digests straight from the GitHub API (not curl:
13+
# release downloads race CDN caching / in-flight uploads and served stale bytes once).
14+
# Fails early if the release or any asset is missing.
15+
SHAS=()
16+
for a in "${ASSETS[@]}"; do
17+
SHAS+=($(gh release view "v$VERSION" --repo ioma8/fishez \
18+
--json assets --jq ".assets[] | select(.name == \"$a\") | .digest" \
19+
| sed 's/^sha256://'))
20+
done
21+
22+
TMP=$(mktemp -d)
23+
trap 'rm -rf "$TMP"' EXIT
24+
25+
gh repo clone "$TAP_REPO" "$TMP/tap" -- --quiet
26+
cd "$TMP/tap"
27+
28+
python3 - "$VERSION" "${SHAS[@]}" <<'PY'
29+
import re, sys
30+
31+
version, shas = sys.argv[1], sys.argv[2:]
32+
path = "Formula/fishez.rb"
33+
s = open(path).read()
34+
s = re.sub(r'version "\d+\.\d+\.\d+"', f'version "{version}"', s, count=1)
35+
it = iter(shas)
36+
s = re.sub(r'sha256 "[0-9a-f]{64}"', lambda m: f'sha256 "{next(it)}"', s)
37+
open(path, "w").write(s)
38+
PY
39+
40+
# Self-check: formula shas must equal the API digests, in order.
41+
GOT=$(grep -oE 'sha256 "[0-9a-f]{64}"' Formula/fishez.rb | grep -oE '[0-9a-f]{64}')
42+
WANT=$(printf '%s\n' "${SHAS[@]}")
43+
if [ "$GOT" != "$WANT" ]; then
44+
echo "Error: formula shas do not match the release:" >&2
45+
paste <(echo "$GOT") <(echo "$WANT") >&2
46+
exit 1
47+
fi
48+
49+
git add Formula/fishez.rb
50+
git commit -q -m "Update fishez to $VERSION"
51+
git push -q origin main
52+
53+
echo "✓ ioma8/tap/fishez updated to $VERSION (sha256s verified against GitHub API)"
54+
echo " brew install ioma8/tap/fishez"

0 commit comments

Comments
 (0)