[CI] Fill in empty draft releases without touching published ones

The existence check skipped release creation for any existing release, which left a draft saved from the GitHub UI empty and silently reused a published release. Inspect the release instead: create it when missing, fill in the title, notes and prerelease flag of an empty draft, and leave a draft that already has a body or a published release untouched.
This commit is contained in:
Lukas Brübach 2026-11-07 22:29:11 +01:00
parent d10b571eca
commit c221371fb1

View file

@ -73,7 +73,7 @@ jobs:
TAG: ${{ steps.configure.outputs.tag }}
run: .ci/prep_release.sh
- name: "Create release"
- name: "Create or update draft release"
if: steps.configure.outputs.tag != null
id: create_release
shell: bash
@ -85,9 +85,15 @@ jobs:
body_path: ${{ steps.prepare.outputs.body_path }}
prerelease: ${{ steps.prepare.outputs.is_beta }}
run: |
if gh release view "$tag_name" >/dev/null 2>&1; then
echo "::warning::Release $tag_name already exists"
else
# A release for this tag may already exist: a maintainer can save a draft in
# the GitHub UI before pushing the tag, or an earlier run may have left one.
# Never touch a published release, and never overwrite a draft that already
# has a body (generated notes or a maintainer's edits) - only fill in an
# empty draft. Prints "<isDraft> <body length>"; empty when there is none.
release_state="$(gh release view "$tag_name" --json isDraft,body \
--template '{{.isDraft}} {{len (or .body "")}}' 2>/dev/null || true)"
if [[ -z "$release_state" ]]; then
args=()
[[ $prerelease == yes ]] && args+=(--prerelease)
@ -95,6 +101,18 @@ jobs:
--target "$target" \
--title "$release_name" \
--notes-file "$body_path"
elif [[ "$release_state" == "true 0" ]]; then
echo "Filling in the empty draft release $tag_name"
args=(--prerelease=false)
[[ $prerelease == yes ]] && args=(--prerelease)
gh release edit "$tag_name" "${args[@]}" \
--title "$release_name" \
--notes-file "$body_path"
elif [[ "$release_state" == true* ]]; then
echo "::warning::Draft release $tag_name already has a body, leaving it untouched"
else
echo "::warning::Release $tag_name is already published, leaving it untouched"
fi
build-linux: