Skip to content

Commit 9f0836d

Browse files
Let a release be drafted instead of published (#39)
Every dispatched release published itself the moment the builds finished, so the notes people read were whatever the workflow generated and the only way to write a real announcement was to edit a release that was already out. A `release` dropdown now decides: draft (the default), publish, or skip. A draft attaches all the builds, named as they always were, and stays invisible until somebody has written it — and because a draft creates no tag, an abandoned one leaves nothing behind. `skip` builds and stops, leaving the artifacts on the run. A tag push has no inputs and still publishes. Pushing a version tag is already the deliberate act this dropdown exists to ask about. Re-running against an existing release leaves its state alone: it must not publish a draft somebody is still writing, nor un-publish one that is already out.
1 parent fab2a50 commit 9f0836d

1 file changed

Lines changed: 43 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ on:
5959
- all # android + ios + macos + windows + linux
6060
- mobile # android + ios only — skips the desktop builds
6161
- android # android only; no macOS runner is started at all
62+
release:
63+
description: 'What to do with the GitHub Release'
64+
type: choice
65+
default: draft
66+
options:
67+
- draft # attach the builds, leave it unpublished to write
68+
- publish # publish immediately, as it used to
69+
- skip # build only; artifacts stay on the run
6270
push:
6371
tags: ['v*']
6472

@@ -854,7 +862,14 @@ jobs:
854862
# Publish whatever succeeded. A Windows build that failed should not hold
855863
# back the Android release people are waiting on — the notes say which
856864
# platforms are in the box.
857-
if: ${{ always() && !cancelled() && needs.version.result == 'success' }}
865+
#
866+
# `release: skip` leaves the builds as run artifacts and touches nothing
867+
# public. A tag push has no inputs at all and still publishes: pushing a
868+
# version tag is already the deliberate act this dropdown exists to ask
869+
# about.
870+
if: >-
871+
${{ always() && !cancelled() && needs.version.result == 'success'
872+
&& (inputs.release || 'publish') != 'skip' }}
858873
runs-on: ubuntu-latest
859874
permissions:
860875
contents: write
@@ -996,10 +1011,26 @@ jobs:
9961011
TAG: ${{ needs.version.outputs.tag }}
9971012
V: ${{ needs.version.outputs.name }}
9981013
SHA: ${{ needs.version.outputs.sha }}
1014+
MODE: ${{ inputs.release || 'publish' }}
9991015
run: |
10001016
set -euo pipefail
1017+
# A draft is the default for a dispatched release: the builds are
1018+
# attached and named, and the release itself stays invisible until
1019+
# somebody has written it and pressed Publish. The generated notes
1020+
# below are a starting point, not the announcement — and a draft
1021+
# does not create the tag either, so an abandoned draft leaves
1022+
# nothing behind.
1023+
# Expanded as ${DRAFT[@]+…} because `set -u` treats an empty array
1024+
# as unbound in bash 3.2, and this step should not depend on which
1025+
# bash the runner happens to ship.
1026+
DRAFT=()
1027+
if [ "${MODE}" = "draft" ]; then DRAFT=(--draft); fi
1028+
10011029
# `--clobber` so re-running a failed publish replaces the assets
1002-
# rather than erroring on the ones that already uploaded.
1030+
# rather than erroring on the ones that already uploaded. An existing
1031+
# release is left at whatever state it already has: re-running must
1032+
# not publish a draft somebody is still writing, nor un-publish one
1033+
# that is already out.
10031034
if gh release view "${TAG}" >/dev/null 2>&1; then
10041035
gh release edit "${TAG}" --title "Sozo v${V}" --notes-file RELEASE_NOTES.md
10051036
gh release upload "${TAG}" rel/* --clobber
@@ -1021,9 +1052,17 @@ jobs:
10211052
gh release create "${TAG}" rel/* \
10221053
--title "Sozo v${V}" \
10231054
--notes-file RELEASE_NOTES.md \
1024-
--target "${SHA}"
1055+
--target "${SHA}" \
1056+
${DRAFT[@]+"${DRAFT[@]}"}
10251057
fi
1026-
gh release view "${TAG}" --json url --jq .url >> "$GITHUB_STEP_SUMMARY"
1058+
{
1059+
if [ "${MODE}" = "draft" ]; then
1060+
echo "### Draft release — not published"
1061+
echo ""
1062+
echo "The builds are attached. Write the notes and press **Publish release**; the \`${TAG}\` tag is created at that point."
1063+
fi
1064+
gh release view "${TAG}" --json url --jq .url
1065+
} >> "$GITHUB_STEP_SUMMARY"
10271066
10281067
# ------------------------------------------------- Deliver (Telegram) --------
10291068
deliver:

0 commit comments

Comments
 (0)