-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathupdate-homebrew-tap.sh
More file actions
executable file
·167 lines (140 loc) · 5.13 KB
/
Copy pathupdate-homebrew-tap.sh
File metadata and controls
executable file
·167 lines (140 loc) · 5.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env bash
# Update the Homebrew tap after a release.
#
# The tap GitHub repo is still Hmbown/homebrew-deepseek-tui until Hunter
# renames it. The formula users type is `codewhale`. The legacy
# `deepseek-tui` formula stays as a deprecated alias for one overlap release.
#
# Expected environment:
# TAG – git tag, e.g. "v0.8.31"
# MANIFEST – path to codewhale-artifacts-sha256.txt
# TAP_REPO – owner/repo of the Homebrew tap
# TOKEN – PAT with contents:write on TAP_REPO (optional; skips if unset)
# FORMULA_OUTPUT – optional local render path used by contract tests
# FORMULA_LEGACY_OUTPUT – optional local render path for the alias formula
set -euo pipefail
: "${TAG:?}"
: "${MANIFEST:?}"
: "${TAP_REPO:?}"
if [ -z "${TOKEN:-}" ] && [ -z "${FORMULA_OUTPUT:-}" ]; then
echo "No Homebrew tap token configured; skipping."
exit 0
fi
VERSION="${TAG#v}"
die() { echo "::error::${1}" >&2; exit 1; }
sha() {
local file="${1:?}"
local val
val="$(awk -v f="${file}" '$2 == f {print $1; exit}' "${MANIFEST}")"
if [ -z "${val}" ]; then
die "Missing binary in checksum manifest: ${file}"
fi
echo "${val}"
}
# --- read checksums ---------------------------------------------------
# One compiled runtime exposed under the two supported command names.
SHA_COD_MACOS_ARM="$(sha codewhale-macos-arm64)"
SHA_CODEW_MACOS_ARM="$(sha codew-macos-arm64)"
SHA_COD_MACOS_X64="$(sha codewhale-macos-x64)"
SHA_CODEW_MACOS_X64="$(sha codew-macos-x64)"
SHA_COD_LINUX_ARM="$(sha codewhale-linux-arm64)"
SHA_CODEW_LINUX_ARM="$(sha codew-linux-arm64)"
SHA_COD_LINUX_X64="$(sha codewhale-linux-x64)"
SHA_CODEW_LINUX_X64="$(sha codew-linux-x64)"
readonly SHA_COD_MACOS_ARM SHA_CODEW_MACOS_ARM
readonly SHA_COD_MACOS_X64 SHA_CODEW_MACOS_X64
readonly SHA_COD_LINUX_ARM SHA_CODEW_LINUX_ARM
readonly SHA_COD_LINUX_X64 SHA_CODEW_LINUX_X64
# --- temp dirs --------------------------------------------------------
FORMULA_FILE="$(mktemp)"
LEGACY_FILE="$(mktemp)"
TAP_DIR="$(mktemp -d)"
trap 'rm -rf "${TAP_DIR}" "${FORMULA_FILE}" "${LEGACY_FILE}"' EXIT
readonly BASE_URL="https://github.com/Hmbown/CodeWhale/releases/download/${TAG}"
render_formula() {
local class_name="${1:?}"
local extra_header="${2:-}"
cat << EOF
class ${class_name} < Formula
desc "Agentic terminal for open-source and open-weight coding models"
homepage "https://github.com/Hmbown/CodeWhale"
version "${VERSION}"
license "MIT"
depends_on "node"
${extra_header}
on_macos do
if Hardware::CPU.arm?
url "${BASE_URL}/codewhale-macos-arm64", using: :nounzip
sha256 "${SHA_COD_MACOS_ARM}"
resource "codew" do
url "${BASE_URL}/codew-macos-arm64", using: :nounzip
sha256 "${SHA_CODEW_MACOS_ARM}"
end
else
url "${BASE_URL}/codewhale-macos-x64", using: :nounzip
sha256 "${SHA_COD_MACOS_X64}"
resource "codew" do
url "${BASE_URL}/codew-macos-x64", using: :nounzip
sha256 "${SHA_CODEW_MACOS_X64}"
end
end
end
on_linux do
if Hardware::CPU.arm?
url "${BASE_URL}/codewhale-linux-arm64", using: :nounzip
sha256 "${SHA_COD_LINUX_ARM}"
resource "codew" do
url "${BASE_URL}/codew-linux-arm64", using: :nounzip
sha256 "${SHA_CODEW_LINUX_ARM}"
end
else
url "${BASE_URL}/codewhale-linux-x64", using: :nounzip
sha256 "${SHA_COD_LINUX_X64}"
resource "codew" do
url "${BASE_URL}/codew-linux-x64", using: :nounzip
sha256 "${SHA_CODEW_LINUX_X64}"
end
end
end
def install
bin.install Dir["*"].first => "codewhale"
resource("codew").stage { bin.install Dir["*"].first => "codew" }
end
test do
system "#{bin}/codewhale", "--version"
system "#{bin}/codew", "--version"
end
end
EOF
}
render_formula "Codewhale" "" > "${FORMULA_FILE}"
render_formula "DeepseekTui" " deprecate! date: \"2026-08-14\", because: \"renamed to codewhale\"
" > "${LEGACY_FILE}"
if [ -n "${FORMULA_OUTPUT:-}" ]; then
cp "${FORMULA_FILE}" "${FORMULA_OUTPUT}"
echo "Rendered Homebrew formula to ${FORMULA_OUTPUT}"
if [ -n "${FORMULA_LEGACY_OUTPUT:-}" ]; then
cp "${LEGACY_FILE}" "${FORMULA_LEGACY_OUTPUT}"
echo "Rendered legacy Homebrew formula to ${FORMULA_LEGACY_OUTPUT}"
fi
exit 0
fi
# --- push to tap repo --------------------------------------------------
ENCODED_TOKEN="$(printf '%s' "${TOKEN}" | python3 -c 'import sys,urllib.parse;print(urllib.parse.quote(sys.stdin.read(),safe=""))')"
TAP_URL="https://x-access-token:${ENCODED_TOKEN}@github.com/${TAP_REPO}.git"
git clone --depth 1 "${TAP_URL}" "${TAP_DIR}"
mkdir -p "${TAP_DIR}/Formula"
cp "${FORMULA_FILE}" "${TAP_DIR}/Formula/codewhale.rb"
cp "${LEGACY_FILE}" "${TAP_DIR}/Formula/deepseek-tui.rb"
cd "${TAP_DIR}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/codewhale.rb Formula/deepseek-tui.rb
if git diff --cached --quiet; then
echo "Formula unchanged (already at ${VERSION}); nothing to push."
exit 0
fi
git commit -m "chore: bump formula to ${VERSION}
Automated update from the release workflow."
git push origin HEAD:main
echo "Pushed formula update to ${TAP_REPO} (v${VERSION})"