feat: improve error handling in release creation step of CI workflow
CI / Windows x64 (push) Failing after 8m26s
CI / Windows x64 (push) Failing after 8m26s
This commit is contained in:
+15
-6
@@ -142,15 +142,24 @@ jobs:
|
|||||||
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||||
TAG: ${{ github.ref_name }}
|
TAG: ${{ github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
# pipefail is required: without it a failing curl would be masked by
|
# Keep this POSIX: the runner executes steps with dash, where
|
||||||
# a successful jq, id would become null, and the assets would be
|
# `set -o pipefail` does not exist. So the curl call is kept out of a
|
||||||
# uploaded to a release that does not exist.
|
# pipeline — under `set -e` a failed command substitution aborts the
|
||||||
|
# step, which is what pipefail would have bought us. Without that, a
|
||||||
|
# failing curl would be masked by a successful jq, id would become
|
||||||
|
# null, and assets would be uploaded to a release that never existed.
|
||||||
# No -x here: the command carries the token.
|
# No -x here: the command carries the token.
|
||||||
set -euo pipefail
|
set -eu
|
||||||
id=$(curl -fsS -X POST "$API/releases" \
|
response=$(curl -fsS -X POST "$API/releases" \
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\"}" | jq -r .id)
|
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\"}")
|
||||||
|
|
||||||
|
id=$(printf '%s' "$response" | jq -r '.id // empty')
|
||||||
|
if [ -z "$id" ]; then
|
||||||
|
echo "no release id in response: $response" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
echo "release $TAG (id $id)"
|
echo "release $TAG (id $id)"
|
||||||
|
|
||||||
for file in dist/*.exe; do
|
for file in dist/*.exe; do
|
||||||
|
|||||||
Reference in New Issue
Block a user