Skip to content

Commit 12c2095

Browse files
tjsingletonclaude
andauthored
fix(release): auto-update Homebrew cask on release (#367)
Add two steps to the update-homebrew job: - Download both darwin installer DMGs and compute their SHA256s - Patch Casks/mcpproxy.rb with the new version and hashes Previously only Formula/mcpproxy.rb was updated automatically; the cask was stuck at v0.20.2 while the formula was at v0.23.1. Fixes #366 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9100e38 commit 12c2095

1 file changed

Lines changed: 52 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,12 +1348,63 @@ jobs:
13481348
echo "Formula created successfully:"
13491349
cat Formula/mcpproxy.rb
13501350
1351+
- name: Download installer DMGs and calculate SHA256 for cask
1352+
run: |
1353+
VERSION=${GITHUB_REF#refs/tags/v}
1354+
BASE_URL="https://github.com/${{ github.repository }}/releases/download/v${VERSION}"
1355+
1356+
for ARCH in arm64 amd64; do
1357+
DMG="mcpproxy-${VERSION}-darwin-${ARCH}-installer.dmg"
1358+
URL="${BASE_URL}/${DMG}"
1359+
echo "Downloading ${DMG}..."
1360+
for i in {1..5}; do
1361+
echo " Attempt ${i}/5..."
1362+
if curl -fsSL "${URL}" -o "${DMG}"; then
1363+
echo " Download successful"
1364+
break
1365+
else
1366+
echo " Download failed, retrying in 10 seconds..."
1367+
sleep 10
1368+
fi
1369+
if [ $i -eq 5 ]; then
1370+
echo "All download attempts failed for ${DMG}"
1371+
curl -I "${URL}" || true
1372+
exit 1
1373+
fi
1374+
done
1375+
SHA=$(sha256sum "${DMG}" | cut -d' ' -f1)
1376+
VAR_NAME="SHA256_CASK_$(echo ${ARCH} | tr '[:lower:]' '[:upper:]')"
1377+
echo "${VAR_NAME}=${SHA}" >> $GITHUB_ENV
1378+
echo " SHA256: ${SHA}"
1379+
rm -f "${DMG}"
1380+
done
1381+
1382+
- name: Update Homebrew cask
1383+
run: |
1384+
cd tap
1385+
mkdir -p Casks
1386+
CASK_FILE="Casks/mcpproxy.rb"
1387+
1388+
if [ ! -f "${CASK_FILE}" ]; then
1389+
echo "Cask file not found at ${CASK_FILE}, skipping cask update"
1390+
exit 0
1391+
fi
1392+
1393+
# Bump version and both sha256 values in place
1394+
sed -i "s/version \"[^\"]*\"/version \"${VERSION}\"/" "${CASK_FILE}"
1395+
# arm64 sha256 is the first occurrence, amd64 is the second
1396+
sed -i "0,/sha256 \"[^\"]*\"/{s/sha256 \"[^\"]*\"/sha256 \"${SHA256_CASK_ARM64}\"/}" "${CASK_FILE}"
1397+
sed -i "0,/sha256 \"${SHA256_CASK_ARM64}\"/{b}; s/sha256 \"[^\"]*\"/sha256 \"${SHA256_CASK_AMD64}\"/" "${CASK_FILE}"
1398+
1399+
echo "Cask updated:"
1400+
cat "${CASK_FILE}"
1401+
13511402
- name: Commit and push changes
13521403
run: |
13531404
cd tap
13541405
git config user.name "github-actions[bot]"
13551406
git config user.email "github-actions[bot]@users.noreply.github.com"
1356-
git add Formula/mcpproxy.rb
1407+
git add Formula/mcpproxy.rb Casks/mcpproxy.rb
13571408
13581409
# Check if there are changes to commit
13591410
if git diff --staged --quiet; then

0 commit comments

Comments
 (0)