fix: handle existing release in create-release job
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:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user