Handle existing releases gracefully, validate release IDs
This commit is contained in:
@@ -36,7 +36,16 @@ jobs:
|
|||||||
DEB=$(ls build/*.deb)
|
DEB=$(ls build/*.deb)
|
||||||
FILENAME=$(basename "${DEB}")
|
FILENAME=$(basename "${DEB}")
|
||||||
|
|
||||||
# Create release (ignore conflict if exists)
|
# Delete existing release for this tag if any
|
||||||
|
OLD_ID=$(curl -s -H "Authorization: token ${TOKEN}" \
|
||||||
|
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id // empty')
|
||||||
|
if [ -n "${OLD_ID}" ] && [ "${OLD_ID}" != "null" ]; then
|
||||||
|
echo "Deleting existing release ${OLD_ID}..."
|
||||||
|
curl -s -X DELETE -H "Authorization: token ${TOKEN}" \
|
||||||
|
"${API}/repos/${REPO}/releases/${OLD_ID}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create release
|
||||||
RELEASE_ID=$(curl -s -X POST \
|
RELEASE_ID=$(curl -s -X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
@@ -44,6 +53,11 @@ jobs:
|
|||||||
"${API}/repos/${REPO}/releases" | jq -r '.id')
|
"${API}/repos/${REPO}/releases" | jq -r '.id')
|
||||||
echo "Release ID: ${RELEASE_ID}"
|
echo "Release ID: ${RELEASE_ID}"
|
||||||
|
|
||||||
|
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
|
||||||
|
echo "ERROR: Failed to create release"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Attach amd64 deb
|
# Attach amd64 deb
|
||||||
curl --fail -X POST \
|
curl --fail -X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
@@ -88,6 +102,11 @@ jobs:
|
|||||||
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id')
|
"${API}/repos/${REPO}/releases/tags/${TAG}" | jq -r '.id')
|
||||||
echo "Release ID: ${RELEASE_ID}"
|
echo "Release ID: ${RELEASE_ID}"
|
||||||
|
|
||||||
|
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
|
||||||
|
echo "ERROR: Release not found for tag ${TAG}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Attach arm64 deb
|
# Attach arm64 deb
|
||||||
curl --fail -X POST \
|
curl --fail -X POST \
|
||||||
-H "Authorization: token ${TOKEN}" \
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user