ci: read the release id correctly and reuse an existing release
CI / test (push) Successful in 3m20s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel SamsonandClaude Sonnet 5.5 committed 2026-10-17 14:17:26 +01:00
1 parent 4b55f5a060
commit 47b12895fd
1 file changed
+8 -2
+8 -2
View File
@@ -62,11 +62,17 @@ jobs:
code=$(curl -sS -o "$resp" -w '%{http_code}' -X POST "$api/releases" \
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":${body}}")
if [ "$code" != "201" ]; then
if [ "$code" = "409" ]; then
# The release already exists (e.g. an earlier run created it): reuse it.
code=$(curl -sS -o "$resp" -w '%{http_code}' -H "Authorization: token $TOKEN" "$api/releases/tags/$TAG")
fi
if [ "$code" != "201" ] && [ "$code" != "200" ]; then
echo "creating the release failed: HTTP $code"; cat "$resp"; echo
exit 1
fi
id=$(sed -n 's/.*"id":\([0-9]*\).*/\1/p' "$resp" | head -1)
# The release's own id is the first key; later "id"s belong to nested objects.
id=$(sed -n 's/^{"id":\([0-9]*\),.*/\1/p' "$resp" | head -1)
[ -n "$id" ] || { echo "could not read the release id"; cat "$resp"; echo; exit 1; }
for f in dist/*; do
echo "uploading $f"
code=$(curl -sS -o "$resp" -w '%{http_code}' -X POST "$api/releases/$id/assets?name=$(basename "$f")" \