ci(release): reuse an existing release when uploading assets
release.yml (push) Invalid workflow file
VoidBuildSystem CI / build-and-test-gcc16 (push) Canceled after 0s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Canceled after 0s
VoidBuildSystem CI / sanitizers-gcc16 (push) Canceled after 0s
VoidBuildSystem CI / fuzz-clang (push) Canceled after 0s

This commit is contained in:
faumaray committed 2026-12-05 14:33:04 +03:00
1 parent e17917be5e
commit 8e0dc8f1cc
1 file changed
+12 -5
+12 -5
View File
@@ -95,12 +95,19 @@ jobs:
body="$(printf 'Release %s\n\nBuilt from %s with the full CTest suite green.\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")" body="$(printf 'Release %s\n\nBuilt from %s with the full CTest suite green.\nSee SHA256SUMS for artifact digests.' "${tag}" "${GITHUB_SHA}")"
payload="$(printf '{"tag_name":"%s","name":"%s","body":"%s","draft":false,"prerelease":false}' \ payload="$(printf '{"tag_name":"%s","name":"%s","body":"%s","draft":false,"prerelease":false}' \
"${tag}" "${tag}" "${body}")" "${tag}" "${tag}" "${body}")"
release_id="$(curl -fsS -X POST -H "Authorization: token ${TOKEN}" \ extract_id() {
-H "Content-Type: application/json" -d "${payload}" \ python3 -c 'import json,sys
"${api}/releases" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("id",""))')" try: print(json.load(sys.stdin).get("id",""))
except Exception: print("")'
}
# The release may already exist (e.g. created by hand for the tag): fall back to it.
created="$(curl -sS -X POST -H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" -d "${payload}" "${api}/releases" || true)"
release_id="$(printf '%s' "${created}" | extract_id)"
if [ -z "${release_id}" ]; then if [ -z "${release_id}" ]; then
release_id="$(curl -fsS -H "Authorization: token ${TOKEN}" \ existing="$(curl -sS -H "Authorization: token ${TOKEN}" \
"${api}/releases/tags/${tag}" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("id",""))')" "${api}/releases/tags/${tag}" || true)"
release_id="$(printf '%s' "${existing}" | extract_id)"
fi fi
test -n "${release_id}" test -n "${release_id}"
for file in dist/*; do for file in dist/*; do