fix: handle existing release in create-release job
Lint & Test / test (push) Successful in 9s
Release / create-release (push) Successful in 1s
Release / build-linux (push) Successful in 25s
Release / build-windows (push) Successful in 58s

If the Gitea release already exists for a tag (e.g. from a retried
workflow), fall back to fetching the existing release ID instead of
failing with KeyError.
This commit is contained in:
2026-03-23 02:24:50 +03:00
parent ddd8788701
commit c76ffb9997
+16 -1
View File
@@ -51,7 +51,22 @@ jobs:
\"prerelease\": $IS_PRE
}")
RELEASE_ID=$(echo "$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
# Extract release ID; if creation failed (already exists), fetch existing
RELEASE_ID=$(echo "$RELEASE" | python3 -c "
import sys, json
data = json.load(sys.stdin)
if 'id' in data:
print(data['id'])
else:
print('FAILED', file=sys.stderr)
print(json.dumps(data, indent=2), file=sys.stderr)
sys.exit(1)
" 2>&1) || {
echo "Create failed, fetching existing release for tag $TAG..."
RELEASE=$(curl -s "$BASE_URL/releases/tags/$TAG" \
-H "Authorization: token $GITEA_TOKEN")
RELEASE_ID=$(echo "$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
}
echo "release_id=$RELEASE_ID" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"