mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
fix: handle both lightweight and annotated tags in update-lolhtml workflow (#21414)
## Summary - Fixes the failing update-lolhtml GitHub Action that was unable to handle lightweight Git tags - The action was failing with "Could not fetch SHA for tag v2.6.0" because it assumed all tags are annotated tag objects - Updated the workflow to properly handle both lightweight tags (direct commit refs) and annotated tags (tag objects) ## Root Cause The lolhtml repository uses lightweight tags (like v2.6.0) which point directly to commits, not to tag objects. The original workflow tried to fetch a tag object for every tag, causing failures when the tag was lightweight. ## Solution The fix adds logic to: 1. Check the tag object type from the Git refs API response 2. For annotated tags: fetch the commit SHA from the tag object (original behavior) 3. For lightweight tags: use the SHA directly from the ref (new behavior) ## Test Plan - [x] Verified the workflow logic handles both tag types correctly - [ ] The next scheduled run should succeed (runs weekly on Sundays at 1 AM UTC) - [ ] Manual workflow dispatch can be used to test immediately 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
22
.github/workflows/update-lolhtml.yml
vendored
22
.github/workflows/update-lolhtml.yml
vendored
@@ -50,15 +50,27 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/cloudflare/lol-html/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
# Get the commit SHA that the tag points to
|
||||||
|
# This handles both lightweight tags (direct commit refs) and annotated tags (tag objects)
|
||||||
|
TAG_REF_RESPONSE=$(curl -sL "https://api.github.com/repos/cloudflare/lol-html/git/refs/tags/$LATEST_TAG")
|
||||||
|
LATEST_TAG_SHA=$(echo "$TAG_REF_RESPONSE" | jq -r '.object.sha')
|
||||||
|
TAG_OBJECT_TYPE=$(echo "$TAG_REF_RESPONSE" | jq -r '.object.type')
|
||||||
|
|
||||||
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
||||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
LATEST_SHA=$(curl -sL "https://api.github.com/repos/cloudflare/lol-html/git/tags/$LATEST_TAG_SHA" | jq -r '.object.sha')
|
|
||||||
if [ -z "$LATEST_SHA" ] || [ "$LATEST_SHA" = "null" ]; then
|
if [ "$TAG_OBJECT_TYPE" = "tag" ]; then
|
||||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG @ $LATEST_TAG_SHA"
|
# This is an annotated tag, we need to get the commit it points to
|
||||||
exit 1
|
LATEST_SHA=$(curl -sL "https://api.github.com/repos/cloudflare/lol-html/git/tags/$LATEST_TAG_SHA" | jq -r '.object.sha')
|
||||||
|
if [ -z "$LATEST_SHA" ] || [ "$LATEST_SHA" = "null" ]; then
|
||||||
|
echo "Error: Could not fetch commit SHA for annotated tag $LATEST_TAG @ $LATEST_TAG_SHA"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# This is a lightweight tag pointing directly to a commit
|
||||||
|
LATEST_SHA="$LATEST_TAG_SHA"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [[ $LATEST_SHA =~ ^[0-9a-f]{40}$ ]]; then
|
if ! [[ $LATEST_SHA =~ ^[0-9a-f]{40}$ ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user