Handle missing Gitea releases in publish workflow (#165)
🧪 CI / 🧪 Test, Type-Check & Build Validation (push) Has been cancelled

Treat a missing Gitea release as the create path and fail on other lookup errors.
This commit is contained in:
yunyingk authored and GitHub committed 2026-09-21 18:42:07 +08:00
commit a3cdfbadf3
1 file changed
+18 -2
+18 -2
View File
@@ -156,9 +156,25 @@ jobs:
NOTES="${TAG_MSG:-Automated release for ${TAG_NAME}}"
echo "==> Creating or finding release on Gitea for ${TAG_NAME}..."
RELEASE_ID=$(curl -fsS --connect-timeout 15 --max-time 30 \
release_lookup=$(curl -sS --connect-timeout 15 --max-time 30 \
-w '\n%{http_code}' \
-H "Authorization: token ${GITEA_TOKEN}" \
"${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
"${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases/tags/${TAG_NAME}")
release_status=$(printf '%s\n' "$release_lookup" | tail -n 1)
release_body=$(printf '%s\n' "$release_lookup" | sed '$d')
case "$release_status" in
200)
RELEASE_ID=$(echo "$release_body" | jq -r '.id // empty')
;;
404)
RELEASE_ID=""
;;
*)
echo "::error::Failed to query the Gitea release (HTTP ${release_status})."
echo "$release_body" | sed -n '1,20p'
exit 1
;;
esac
if [ -z "$RELEASE_ID" ]; then
RELEASE_RESP=$(curl -fsS --connect-timeout 15 --max-time 30 -X POST "${GITEA_HOST}/api/v1/repos/${GITEA_REPO}/releases" \