Files
codewhale/.github/scripts/update-homebrew-tap.sh
T
PMX b4d1bce58b fix: Homebrew formula downloads legacy shim instead of codewhale dispatcher (#2105)
The formula downloaded deepseek-macos-arm64 (the deprecation shim) as the
main binary.  After the rebranding, deepseek is just a wrapper that spawns
codewhale, but codewhale was never installed — causing "codewhale not
found on PATH" for every Homebrew user.

Now the formula downloads codewhale-* as the primary binary and installs
all four artifacts: codewhale, codewhale-tui, deepseek (legacy shim), and
deepseek-tui (legacy TUI shim).

Closes #2104

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 10:30:25 -05:00

181 lines
5.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Update the Homebrew tap at Hmbown/homebrew-deepseek-tui after a release.
#
# Expected environment:
# TAG git tag, e.g. "v0.8.31"
# MANIFEST path to deepseek-artifacts-sha256.txt
# TAP_REPO owner/repo of the Homebrew tap
# TOKEN PAT with contents:write on TAP_REPO (optional; skips if unset)
set -euo pipefail
: "${TAG:?}"
: "${MANIFEST:?}"
: "${TAP_REPO:?}"
if [ -z "${TOKEN:-}" ]; 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 ---------------------------------------------------
# Canonical dispatcher and TUI
readonly SHA_COD_MACOS_ARM="$(sha codewhale-macos-arm64)"
readonly SHA_TUI_MACOS_ARM="$(sha codewhale-tui-macos-arm64)"
readonly SHA_COD_MACOS_X64="$(sha codewhale-macos-x64)"
readonly SHA_TUI_MACOS_X64="$(sha codewhale-tui-macos-x64)"
readonly SHA_COD_LINUX_ARM="$(sha codewhale-linux-arm64)"
readonly SHA_TUI_LINUX_ARM="$(sha codewhale-tui-linux-arm64)"
readonly SHA_COD_LINUX_X64="$(sha codewhale-linux-x64)"
readonly SHA_TUI_LINUX_X64="$(sha codewhale-tui-linux-x64)"
# Legacy shims (removed in v0.9.0)
readonly SHA_LEG_MACOS_ARM="$(sha deepseek-macos-arm64)"
readonly SHA_LEG_TUI_MACOS_ARM="$(sha deepseek-tui-macos-arm64)"
readonly SHA_LEG_MACOS_X64="$(sha deepseek-macos-x64)"
readonly SHA_LEG_TUI_MACOS_X64="$(sha deepseek-tui-macos-x64)"
readonly SHA_LEG_LINUX_ARM="$(sha deepseek-linux-arm64)"
readonly SHA_LEG_TUI_LINUX_ARM="$(sha deepseek-tui-linux-arm64)"
readonly SHA_LEG_LINUX_X64="$(sha deepseek-linux-x64)"
readonly SHA_LEG_TUI_LINUX_X64="$(sha deepseek-tui-linux-x64)"
# --- temp dirs --------------------------------------------------------
FORMULA_FILE="$(mktemp)"
TAP_DIR="$(mktemp -d)"
trap 'rm -rf "${TAP_DIR}" "${FORMULA_FILE}"' EXIT
# --- generate formula --------------------------------------------------
readonly BASE_URL="https://github.com/Hmbown/CodeWhale/releases/download/${TAG}"
cat > "${FORMULA_FILE}" << EOF
class DeepseekTui < Formula
desc "Terminal-native coding agent for DeepSeek V4"
homepage "https://github.com/Hmbown/CodeWhale"
version "${VERSION}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "${BASE_URL}/codewhale-macos-arm64", using: :nounzip
sha256 "${SHA_COD_MACOS_ARM}"
resource "tui" do
url "${BASE_URL}/codewhale-tui-macos-arm64", using: :nounzip
sha256 "${SHA_TUI_MACOS_ARM}"
end
resource "legacy-shim" do
url "${BASE_URL}/deepseek-macos-arm64", using: :nounzip
sha256 "${SHA_LEG_MACOS_ARM}"
end
resource "legacy-tui-shim" do
url "${BASE_URL}/deepseek-tui-macos-arm64", using: :nounzip
sha256 "${SHA_LEG_TUI_MACOS_ARM}"
end
else
url "${BASE_URL}/codewhale-macos-x64", using: :nounzip
sha256 "${SHA_COD_MACOS_X64}"
resource "tui" do
url "${BASE_URL}/codewhale-tui-macos-x64", using: :nounzip
sha256 "${SHA_TUI_MACOS_X64}"
end
resource "legacy-shim" do
url "${BASE_URL}/deepseek-macos-x64", using: :nounzip
sha256 "${SHA_LEG_MACOS_X64}"
end
resource "legacy-tui-shim" do
url "${BASE_URL}/deepseek-tui-macos-x64", using: :nounzip
sha256 "${SHA_LEG_TUI_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 "tui" do
url "${BASE_URL}/codewhale-tui-linux-arm64", using: :nounzip
sha256 "${SHA_TUI_LINUX_ARM}"
end
resource "legacy-shim" do
url "${BASE_URL}/deepseek-linux-arm64", using: :nounzip
sha256 "${SHA_LEG_LINUX_ARM}"
end
resource "legacy-tui-shim" do
url "${BASE_URL}/deepseek-tui-linux-arm64", using: :nounzip
sha256 "${SHA_LEG_TUI_LINUX_ARM}"
end
else
url "${BASE_URL}/codewhale-linux-x64", using: :nounzip
sha256 "${SHA_COD_LINUX_X64}"
resource "tui" do
url "${BASE_URL}/codewhale-tui-linux-x64", using: :nounzip
sha256 "${SHA_TUI_LINUX_X64}"
end
resource "legacy-shim" do
url "${BASE_URL}/deepseek-linux-x64", using: :nounzip
sha256 "${SHA_LEG_LINUX_X64}"
end
resource "legacy-tui-shim" do
url "${BASE_URL}/deepseek-tui-linux-x64", using: :nounzip
sha256 "${SHA_LEG_TUI_LINUX_X64}"
end
end
end
def install
bin.install Dir["*"].first => "codewhale"
resource("tui").stage { bin.install Dir["*"].first => "codewhale-tui" }
resource("legacy-shim").stage { bin.install Dir["*"].first => "deepseek" }
resource("legacy-tui-shim").stage { bin.install Dir["*"].first => "deepseek-tui" }
end
test do
system "#{bin}/codewhale", "--version"
end
end
EOF
# --- 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/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/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})"