Skip to content

Commit 04864e9

Browse files
authored
Use a draft release instead of a pre-release for artifact staging (#1081)
Pre-releases do not allow additional artifact uploads when the GitHub "immutable release" feature is used. It's not clear to me why we use a pre-release instead of a draft release, which is not user visible and seems generally superior for staging artifacts.
1 parent 4fa65c0 commit 04864e9

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ jobs:
130130
with:
131131
tag: ${{ github.event.inputs.tag }}
132132
secrets: inherit
133+

CONTRIBUTING.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Releases
3737
To cut a release, wait for the "MacOS Python build", "Linux Python build", and
3838
"Windows Python build" GitHub Actions to complete successfully on the target commit.
3939

40-
Then, run the "Release" GitHub Action to create the release, populate the release artifacts (by
41-
downloading the artifacts from each workflow, and uploading them to the GitHub Release), and promote
42-
the SHA via the `latest-release` branch.
40+
Then, run the "Release" GitHub Action to create a draft release, populate the release artifacts
41+
(by downloading the artifacts from each workflow, and uploading them to the GitHub Release),
42+
publish the release, and promote the SHA via the `latest-release` branch.
4343

4444
The "Release" GitHub Action takes, as input, a tag (assumed to be a date in `YYYYMMDD` format) and
4545
the commit SHA referenced above.
@@ -49,8 +49,8 @@ with the tag `20240419` and the commit SHA `29abc56954fbf5ea812f7fbc3e42d87787d4
4949
once the "MacOS Python build", "Linux Python build", and "Windows Python build" workflows have
5050
run to completion on `29abc56`.
5151

52-
When the "Release" workflow is complete, populate the release notes in the GitHub UI and promote
53-
the pre-release to a full release, again in the GitHub UI.
52+
When the "Release" workflow is complete, the release will have been published and version metadata
53+
will have been updated. You can then refine the release notes in the GitHub UI.
5454

5555
At any stage, you can run the "Release" workflow in dry-run mode to avoid uploading artifacts to
5656
GitHub. Dry-run mode can be executed before or after creating the release itself.

Justfile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,35 @@ release-set-latest-release tag:
7171

7272
git switch main
7373

74-
# Create a GitHub release object, or reuse an existing prerelease.
74+
# Create a GitHub release object, or reuse an existing draft release.
7575
release-create tag:
7676
#!/usr/bin/env bash
7777
set -euo pipefail
78-
prerelease_exists=$(gh release view {{tag}} --json isPrerelease -t '{{{{.isPrerelease}}' 2>&1 || true)
79-
case "$prerelease_exists" in
78+
draft_exists=$(gh release view {{tag}} --json isDraft -t '{{{{.isDraft}}' 2>&1 || true)
79+
case "$draft_exists" in
8080
true)
81-
echo "note: updating existing prerelease {{tag}}"
81+
echo "note: updating existing draft release {{tag}}"
8282
;;
8383
false)
84-
echo "error: release {{tag}} already exists"
84+
echo "error: release {{tag}} already exists and is not a draft"
8585
exit 1
8686
;;
8787
"release not found")
88-
gh release create {{tag}} --prerelease --notes TBD --verify-tag
88+
gh release create {{tag}} --draft --notes TBD --verify-tag
8989
;;
9090
*)
91-
echo "error: unexpected gh cli output: $prerelease_exists"
91+
echo "error: unexpected gh cli output: $draft_exists"
9292
exit 1
9393
;;
9494
esac
9595

96+
# Publish the draft GitHub release and promote the tag to latest-release.
97+
release-finalize tag:
98+
#!/usr/bin/env bash
99+
set -euo pipefail
100+
gh release edit {{tag}} --draft=false --latest
101+
just release-set-latest-release {{tag}}
102+
96103
# Upload release artifacts to an S3-compatible mirror bucket with the correct release names.
97104
# AWS credentials are read from the standard AWS_* environment variables.
98105
# Requires `release-run` to have been run so that dist/SHA256SUMS exists.
@@ -122,7 +129,7 @@ release-run token commit tag:
122129
just release-download-distributions {{token}} {{commit}}
123130
datetime=$(ls dist/cpython-3.10.*-x86_64-unknown-linux-gnu-install_only-*.tar.gz | awk -F- '{print $8}' | awk -F. '{print $1}')
124131
just release-upload-distributions {{token}} ${datetime} {{tag}}
125-
just release-set-latest-release {{tag}}
132+
just release-finalize {{tag}}
126133

127134
# Perform a release in dry-run mode.
128135
release-dry-run token commit tag:

0 commit comments

Comments
 (0)