Skip to content

Commit 3e8bd3c

Browse files
beriberikixclaude
andcommitted
Make the tap dispatch and checksum steps fail when they fail
The v0.5.0 release exposed two steps that reported success while doing nothing. The repository dispatch to the tap returned HTTP 401 and the step printed "Repository dispatch event sent successfully" regardless, because the curl had no --fail and nothing inspected the response. The formula was left pointing at v0.1.38-test, a release that had been deleted, so brew install fetched a 404. The status is now captured and anything other than 204 fails the job with the response body and a note on what a 401 or 404 implies. HOMEBREW_TAP_DISPATCH_TOKEN is set but was last updated a year ago, so the credential behind it has expired — the emptiness check added alongside would not have caught that, which is why the status check is the real guard. The checksum step globbed for "*.macos" while the artifacts are named usbipd-vX.Y.Z-macos, ending in "-macos". The glob never matched, so checksums-v0.5.0.sha256 shipped covering only the tarballs, with no hash for the binary users actually download — the formula's sha256 had to be computed by hand. Fixed, with a guard that fails the job if no binary checksum is recorded. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017rmyikdjWveP99ZUCDLY89
1 parent f823571 commit 3e8bd3c

1 file changed

Lines changed: 35 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,15 @@ jobs:
362362
363363
echo "📊 Generating checksums..."
364364
# Only checksum files, not directories
365-
find . -maxdepth 1 -type f \( -name "*.macos" -o -name "*.tar.gz" \) -exec shasum -a 256 {} \; > "$CHECKSUMS_FILE"
365+
# The binaries are named usbipd-vX.Y.Z-macos, so they end in "-macos" and the
366+
# old "*.macos" glob never matched one. checksums-v0.5.0.sha256 shipped
367+
# covering only the tarballs, with no hash for the binary anyone downloads.
368+
find . -maxdepth 1 -type f \( -name "*-macos" -o -name "*.tar.gz" \) -exec shasum -a 256 {} \; > "$CHECKSUMS_FILE"
369+
370+
if ! grep -q -- "-macos" "$CHECKSUMS_FILE"; then
371+
echo "::error title=Checksums Incomplete::No binary checksum was recorded"
372+
exit 1
373+
fi
366374
367375
# Extract specific checksums for metadata generation
368376
CLI_SHA256=$(shasum -a 256 usbipd-${{ needs.release-validation.outputs.version }}-macos | cut -d' ' -f1)
@@ -788,8 +796,18 @@ jobs:
788796
echo " • Event: formula_update"
789797
echo " • Version: $VERSION"
790798
791-
# Send repository dispatch event using curl for better JSON handling
792-
curl -X POST \
799+
# The token is a PAT with access to the tap repository. GITHUB_TOKEN cannot
800+
# write to another repository, so an absent secret means the dispatch silently
801+
# 401s — which is exactly what happened for v0.5.0.
802+
if [ -z "${{ secrets.HOMEBREW_TAP_DISPATCH_TOKEN }}" ]; then
803+
echo "::error title=Missing Token::HOMEBREW_TAP_DISPATCH_TOKEN is not set; the tap cannot be updated"
804+
exit 1
805+
fi
806+
807+
# Capture the status. Without this the step reported success on a 401 and the
808+
# formula sat pointing at a deleted release.
809+
HTTP_STATUS=$(curl -sS -o /tmp/dispatch-response.json -w '%{http_code}' \
810+
-X POST \
793811
-H "Authorization: token ${{ secrets.HOMEBREW_TAP_DISPATCH_TOKEN }}" \
794812
-H "Accept: application/vnd.github.v3+json" \
795813
-H "Content-Type: application/json" \
@@ -806,9 +824,20 @@ jobs:
806824
"triggered_by": "automated-release",
807825
"prerelease": '"$PRERELEASE"'
808826
}
809-
}'
810-
811-
echo "::notice title=Dispatch Sent::Repository dispatch event sent successfully"
827+
}')
828+
829+
# A successful dispatch is 204 No Content.
830+
if [ "$HTTP_STATUS" != "204" ]; then
831+
echo "::error title=Dispatch Failed::Tap dispatch returned HTTP $HTTP_STATUS"
832+
cat /tmp/dispatch-response.json 2>/dev/null || true
833+
echo ""
834+
echo "401 or 404 means HOMEBREW_TAP_DISPATCH_TOKEN is missing, expired, or"
835+
echo "lacks access to beriberikix/homebrew-usbipd-mac."
836+
echo "The formula will keep pointing at the previous release until this is fixed."
837+
exit 1
838+
fi
839+
840+
echo "::notice title=Dispatch Sent::Repository dispatch accepted (HTTP 204)"
812841
echo "✅ Formula update event dispatched to tap repository"
813842
echo "🔗 Monitor tap repository: https://github.com/beriberikix/homebrew-usbipd-mac/actions"
814843
echo "::endgroup::"

0 commit comments

Comments
 (0)