Skip to content

Commit b4e5bcf

Browse files
committed
fix: use curl for tag creation (raw JSON, not form-encoded) [skip-version]
- gh api -f sends form-encoded data, API expects JSON body - Use curl -X POST with -d for proper JSON body format - Returns HTTP 201 (created) or 422 (already exists)
1 parent 55b6e9d commit b4e5bcf

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

.github/workflows/build-and-publish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ jobs:
155155
echo "Tagging $repo@$VERSION (from $branch)"
156156
sha=$(git ls-remote "https://github.com/$repo.git" "refs/heads/$branch" | awk '{print $1}')
157157
if [ -n "$sha" ]; then
158-
# GH_TOKEN env var makes gh use PAT for all API calls
159-
# Create lightweight tag: POST to /git/refs/{ref} with sha body
160-
if gh api "repos/$repo/git/refs/refs/tags/$VERSION" \
161-
--method POST \
162-
-f sha="$sha"; then
158+
# Use curl to POST raw JSON (gh api -f sends form-encoded, not JSON)
159+
status=$(curl -s -o /dev/null -w '%{http_code}' \
160+
-X POST "https://api.github.com/repos/$repo/git/refs/refs/tags/$VERSION" \
161+
-H "Authorization: token $LOCALPIBOX_PAT" \
162+
-H "Accept: application/vnd.github+json" \
163+
-d "{\"sha\": \"$sha\"}")
164+
if [ "$status" = "201" ] || [ "$status" = "422" ]; then
163165
echo " ✅ $repo@$VERSION"
164-
elif gh api "repos/$repo/git/ref/tags/$VERSION" 2>/dev/null > /dev/null; then
165-
echo " ✅ $repo@$VERSION (already exists)"
166166
else
167-
echo " ⚠️ $repo tag creation failed"
167+
echo " ⚠️ $repo tag creation failed (HTTP $status)"
168168
fi
169169
else
170170
echo " ⚠️ $repo:$branch not found, skipping tag"

0 commit comments

Comments
 (0)