mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 19:43:26 -08:00
[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:
parent
d10b571eca
commit
c221371fb1
1 changed files with 22 additions and 4 deletions
26
.github/workflows/desktop-build.yml
vendored
26
.github/workflows/desktop-build.yml
vendored
|
|
@ -73,7 +73,7 @@ jobs:
|
||||||
TAG: ${{ steps.configure.outputs.tag }}
|
TAG: ${{ steps.configure.outputs.tag }}
|
||||||
run: .ci/prep_release.sh
|
run: .ci/prep_release.sh
|
||||||
|
|
||||||
- name: "Create release"
|
- name: "Create or update draft release"
|
||||||
if: steps.configure.outputs.tag != null
|
if: steps.configure.outputs.tag != null
|
||||||
id: create_release
|
id: create_release
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
@ -85,9 +85,15 @@ jobs:
|
||||||
body_path: ${{ steps.prepare.outputs.body_path }}
|
body_path: ${{ steps.prepare.outputs.body_path }}
|
||||||
prerelease: ${{ steps.prepare.outputs.is_beta }}
|
prerelease: ${{ steps.prepare.outputs.is_beta }}
|
||||||
run: |
|
run: |
|
||||||
if gh release view "$tag_name" >/dev/null 2>&1; then
|
# A release for this tag may already exist: a maintainer can save a draft in
|
||||||
echo "::warning::Release $tag_name already exists"
|
# the GitHub UI before pushing the tag, or an earlier run may have left one.
|
||||||
else
|
# 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=()
|
args=()
|
||||||
[[ $prerelease == yes ]] && args+=(--prerelease)
|
[[ $prerelease == yes ]] && args+=(--prerelease)
|
||||||
|
|
||||||
|
|
@ -95,6 +101,18 @@ jobs:
|
||||||
--target "$target" \
|
--target "$target" \
|
||||||
--title "$release_name" \
|
--title "$release_name" \
|
||||||
--notes-file "$body_path"
|
--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
|
fi
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue