CI: 409/Body-Pfad entgiftet (keine -f-Curls, || true-Griffe); v0.1.5
This commit is contained in:
@ -40,29 +40,41 @@ jobs:
|
||||
VER="$GITHUB_REF_NAME"
|
||||
set -u
|
||||
|
||||
release_body() {
|
||||
echo -n "{\"tag_name\":\"$VER\",\"name\":\"Hörwerk $VER\",\"body\":\"Release $VER — AppImage, deb und Arch-Paket.\",\"draft\":false,\"prerelease\":false}"
|
||||
}
|
||||
post_release() {
|
||||
body=$(release_body)
|
||||
curl -sS -X POST \
|
||||
-H "Authorization: token $HW_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"tag_name\":\"$VER\",\"name\":\"Hörwerk $VER\",\"body\":\"Release $VER — AppImage, deb und Arch-Paket.\",\"draft\":false,\"prerelease\":false}" \
|
||||
-d "$body" \
|
||||
-w '\n%{http_code}' \
|
||||
-o /tmp/hw-rel-body.json \
|
||||
"$HW_API/releases"
|
||||
$curl_out_flag \
|
||||
"$HW_API/releases" || true
|
||||
}
|
||||
get_release() {
|
||||
curl -sS -H "Authorization: token $HW_TOKEN" \
|
||||
-w '\n%{http_code}' -o /tmp/hw-rel-body.json \
|
||||
"$HW_API/releases/tags/$VER"
|
||||
-w '\n%{http_code}' -o $curl_out_flag \
|
||||
"$HW_API/releases/tags/$VER" || true
|
||||
}
|
||||
|
||||
# Body-Datei immer beschreiben (auch bei Fehlstatus)
|
||||
curl_out_flag=('/tmp/hw-rel-body.json')
|
||||
code=$(post_release | tail -n1)
|
||||
RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body.json | head -n1 | grep -o '[0-9]*')
|
||||
if [ -z "$RID" ] && [ "$code" != "201" ]; then
|
||||
get_release >/dev/null
|
||||
RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body.json | head -n1 | grep -o '[0-9]*')
|
||||
fi
|
||||
body_text=$(cat /tmp/hw-rel-body.json 2>/dev/null || echo)
|
||||
RID=$(echo "$body_text" | grep -o '"id": *[0-9]*' | head -n1 | grep -o '[0-9]*' || true)
|
||||
if [ -z "$RID" ]; then
|
||||
echo "Release-ID konnte nicht ermittelt werden (code=$code)"
|
||||
echo "POST-Code: $code — Fallback: Suche via Tag"
|
||||
curl_out_flag=('/tmp/hw-rel-body.json')
|
||||
get_release | tail -n1
|
||||
body_text=$(cat /tmp/hw-rel-body.json 2>/dev/null || echo)
|
||||
RID=$(echo "$body_text" | grep -o '"id": *[0-9]*' | head -n1 | grep -o '[0-9]*' || true)
|
||||
fi
|
||||
RID=${RID:-}
|
||||
if [ -z "$RID" ]; then
|
||||
echo "Release-ID nicht ermittelbar — Body:"
|
||||
echo "$body_text" | head -c 400
|
||||
exit 1
|
||||
fi
|
||||
echo "Release-ID: $RID"
|
||||
@ -111,20 +123,20 @@ jobs:
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{\"tag_name\":\"$VER\",\"name\":\"Hörwerk $VER\",\"body\":\"Release $VER — AppImage, deb und Arch-Paket.\",\"draft\":false,\"prerelease\":false}" \
|
||||
-w '\n%{http_code}' \
|
||||
-o /tmp/hw-rel-body2.json \
|
||||
-o /tmp/hw-rel-body.json \
|
||||
"$HW_API/releases"
|
||||
}
|
||||
get_release() {
|
||||
curl -sS -H "Authorization: token $HW_TOKEN" \
|
||||
-w '\n%{http_code}' -o /tmp/hw-rel-body2.json \
|
||||
-w '\n%{http_code}' -o /tmp/hw-rel-body.json \
|
||||
"$HW_API/releases/tags/$VER"
|
||||
}
|
||||
|
||||
code=$(post_release | tail -n1)
|
||||
RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body2.json | head -n1 | grep -o '[0-9]*')
|
||||
RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body.json | head -n1 | grep -o '[0-9]*')
|
||||
if [ -z "$RID" ] && [ "$code" != "201" ]; then
|
||||
get_release >/dev/null
|
||||
RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body2.json | head -n1 | grep -o '[0-9]*')
|
||||
RID=$(grep -o '"id": *[0-9]*' /tmp/hw-rel-body.json | head -n1 | grep -o '[0-9]*')
|
||||
fi
|
||||
if [ -z "$RID" ]; then
|
||||
echo "Release-ID konnte nicht ermittelt werden (code=$code)"
|
||||
|
||||
Reference in New Issue
Block a user