fix(release): improve release upload URL handling
CI / Test (push) Successful in 25s
CI / Build (push) Successful in 22s

* Added error handling for missing upload URL in release creation
* Replaced Python command with simpler grep and cut for extracting upload URL
* Removed unnecessary upload URL artifact upload step
This commit is contained in:
Hein
2026-06-29 09:16:53 +02:00
parent 2bee0e1ed9
commit dd91e7ed5a
+13 -15
View File
@@ -73,22 +73,22 @@ jobs:
BODY="## What's changed"$'\n'"${NOTES}" BODY="## What's changed"$'\n'"${NOTES}"
BODY_JSON=$(printf '%s' "$BODY" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))') BODY_JSON=$(printf '%s' "$BODY" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')
echo "Creating release ${TAG} via ${API}..."
RELEASE=$(curl -s -X POST "$API" \ RELEASE=$(curl -s -X POST "$API" \
-H "Authorization: token ${GITHUB_TOKEN}" \ -H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"body\":${BODY_JSON},\"draft\":true}") -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"body\":${BODY_JSON},\"draft\":true}")
echo "API response: $RELEASE"
UPLOAD_URL=$(echo "$RELEASE" | python3 -c "import json,sys,re; r=json.load(sys.stdin); print(re.sub(r'\{[^}]*\}','',r['upload_url']))") UPLOAD_URL=$(echo "$RELEASE" | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4 | sed 's/{[^}]*}//')
if [ -z "$UPLOAD_URL" ]; then if [ -z "$UPLOAD_URL" ]; then
echo "Failed to create release: $RELEASE" echo "upload_url not found in response — aborting"
exit 1 exit 1
fi fi
echo "$UPLOAD_URL" > /tmp/upload_url.txt
for f in pgtidy-*; do for f in pgtidy-*; do
echo "Uploading $f..." echo "Uploading $f..."
curl -s -X POST "${UPLOAD_URL}?name=${f}" \ curl -sf -X POST "${UPLOAD_URL}?name=${f}" \
-H "Authorization: token ${GITHUB_TOKEN}" \ -H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary "@${f}" > /dev/null --data-binary "@${f}" > /dev/null
@@ -96,12 +96,6 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: upload-url
path: /tmp/upload_url.txt
retention-days: 1
pkg-deb: pkg-deb:
name: Debian packages name: Debian packages
needs: release needs: release
@@ -140,7 +134,8 @@ jobs:
TAG="${{ github.event.inputs.tag || github.ref_name }}" TAG="${{ github.event.inputs.tag || github.ref_name }}"
RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \ RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \
-H "Authorization: token ${GITHUB_TOKEN}") -H "Authorization: token ${GITHUB_TOKEN}")
UPLOAD_URL=$(echo "$RELEASE" | python3 -c "import json,sys,re; r=json.load(sys.stdin); print(re.sub(r'\{[^}]*\}','',r['upload_url']))") UPLOAD_URL=$(echo "$RELEASE" | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4 | sed 's/{[^}]*}//')
[ -z "$UPLOAD_URL" ] && { echo "upload_url not found: $RELEASE"; exit 1; }
for f in *.deb; do for f in *.deb; do
echo "Uploading $(basename "$f")..." echo "Uploading $(basename "$f")..."
curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \ curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \
@@ -205,7 +200,8 @@ jobs:
TAG="${{ github.event.inputs.tag || github.ref_name }}" TAG="${{ github.event.inputs.tag || github.ref_name }}"
RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \ RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \
-H "Authorization: token ${GITHUB_TOKEN}") -H "Authorization: token ${GITHUB_TOKEN}")
UPLOAD_URL=$(echo "$RELEASE" | python3 -c "import json,sys,re; r=json.load(sys.stdin); print(re.sub(r'\{[^}]*\}','',r['upload_url']))") UPLOAD_URL=$(echo "$RELEASE" | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4 | sed 's/{[^}]*}//')
[ -z "$UPLOAD_URL" ] && { echo "upload_url not found: $RELEASE"; exit 1; }
while IFS= read -r f; do while IFS= read -r f; do
echo "Uploading $(basename "$f")..." echo "Uploading $(basename "$f")..."
curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \ curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \
@@ -331,7 +327,8 @@ jobs:
TAG="${{ github.event.inputs.tag || github.ref_name }}" TAG="${{ github.event.inputs.tag || github.ref_name }}"
RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \ RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \
-H "Authorization: token ${GITHUB_TOKEN}") -H "Authorization: token ${GITHUB_TOKEN}")
UPLOAD_URL=$(echo "$RELEASE" | python3 -c "import json,sys,re; r=json.load(sys.stdin); print(re.sub(r'\{[^}]*\}','',r['upload_url']))") UPLOAD_URL=$(echo "$RELEASE" | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4 | sed 's/{[^}]*}//')
[ -z "$UPLOAD_URL" ] && { echo "upload_url not found: $RELEASE"; exit 1; }
for f in editors/vscode/*.vsix; do for f in editors/vscode/*.vsix; do
echo "Uploading $(basename "$f")..." echo "Uploading $(basename "$f")..."
curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \ curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \
@@ -364,7 +361,8 @@ jobs:
TAG="${{ github.event.inputs.tag || github.ref_name }}" TAG="${{ github.event.inputs.tag || github.ref_name }}"
RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \ RELEASE=$(curl -s "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}" \
-H "Authorization: token ${GITHUB_TOKEN}") -H "Authorization: token ${GITHUB_TOKEN}")
UPLOAD_URL=$(echo "$RELEASE" | python3 -c "import json,sys,re; r=json.load(sys.stdin); print(re.sub(r'\{[^}]*\}','',r['upload_url']))") UPLOAD_URL=$(echo "$RELEASE" | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4 | sed 's/{[^}]*}//')
[ -z "$UPLOAD_URL" ] && { echo "upload_url not found: $RELEASE"; exit 1; }
for f in editors/datagrip/build/distributions/*.zip; do for f in editors/datagrip/build/distributions/*.zip; do
echo "Uploading $(basename "$f")..." echo "Uploading $(basename "$f")..."
curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \ curl -s -X POST "${UPLOAD_URL}?name=$(basename "$f")" \