Create release tags via POST /tags — Gitea has no POST /git/refs
build-apk / build (push) Successful in 13m7s

POST /git/refs returns 405 with an empty body on Gitea, which crashed
the tag step (json decode of ''). Use the tags API:
POST /repos/{owner}/{repo}/tags with {tag_name, target} (201), and
409 'tag already exists' is handled gracefully.
This commit is contained in:
2026-08-12 01:17:31 +03:00
parent ec0a134b5a
commit b8ee8be9eb
+5 -4
View File
@@ -144,15 +144,16 @@ jobs:
API="${{ github.api_url }}/repos/${GITHUB_REPOSITORY}" API="${{ github.api_url }}/repos/${GITHUB_REPOSITORY}"
TAG_COMMIT=$(git rev-parse HEAD) TAG_COMMIT=$(git rev-parse HEAD)
echo "== Creating tag v${NEXT_VERSION} at ${TAG_COMMIT} ==" echo "== Creating tag v${NEXT_VERSION} at ${TAG_COMMIT} =="
TAG_RESP=$(curl -sS -X POST "$API/git/refs" \ # Gitea has no POST /git/refs (405); use the tags API instead.
TAG_RESP=$(curl -sS -X POST "$API/tags" \
-H "Authorization: token $GITHUB_TOKEN" \ -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"ref\":\"refs/tags/v${NEXT_VERSION}\",\"sha\":\"${TAG_COMMIT}\"}") -d "{\"tag_name\":\"v${NEXT_VERSION}\",\"target\":\"${TAG_COMMIT}\"}")
echo "$TAG_RESP" | python3 -c " echo "$TAG_RESP" | python3 -c "
import json, sys import json, sys
d = json.load(sys.stdin) d = json.load(sys.stdin)
if 'ref' in d: if 'name' in d:
print(' tag created: ' + d['ref']) print(' tag created: ' + d['name'])
elif 'message' in d and 'already' in str(d['message']).lower(): elif 'message' in d and 'already' in str(d['message']).lower():
print(' tag already exists: ' + str(d['message'])) print(' tag already exists: ' + str(d['message']))
else: else: