Skip to content

Commit 4b874a3

Browse files
committed
code review feedback
1 parent 9cbf70e commit 4b874a3

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

‎.github/workflows/publish-pypi.yml‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ jobs:
3030
version: ${{ steps.tag.outputs.version }}
3131
prerelease: ${{ steps.tag.outputs.prerelease }}
3232
steps:
33+
- name: Require the workflow to run from main
34+
env:
35+
REF: ${{ github.ref }}
36+
run: |
37+
if [ "$REF" != "refs/heads/main" ]; then
38+
echo "::error::Run this workflow from the main branch, not $REF"
39+
exit 1
40+
fi
3341
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3442
with:
3543
fetch-depth: 0
@@ -146,7 +154,7 @@ jobs:
146154
skip-existing: true
147155

148156
github-release:
149-
name: Create draft GitHub release
157+
name: Create GitHub release
150158
needs: [validate, pypi]
151159
runs-on: ubuntu-latest
152160
# Kept apart from the pypi job so that the OIDC token and the write
@@ -166,17 +174,15 @@ jobs:
166174
with:
167175
name: notes
168176
path: .
169-
- name: Create the draft release
177+
- name: Create the release
170178
run: |
171-
# gh release view cannot see drafts, so list releases instead
172-
existing=$(gh api "repos/$GH_REPO/releases" --paginate --jq ".[] | select(.tag_name == \"$TAG\") | .html_url")
173-
if [ -n "$existing" ]; then
174-
echo "::error::A release for $TAG exists already: $existing. Delete it and re-run."
179+
if gh release view "$TAG" > /dev/null 2>&1; then
180+
echo "::error::A release for $TAG exists already. Delete it and re-run."
175181
exit 1
176182
fi
177-
flags="--draft"
183+
flags=""
178184
if [ "$PRERELEASE" = "true" ]; then
179-
flags="$flags --prerelease"
185+
flags="--prerelease"
180186
fi
181187
gh release create "$TAG" dist/* \
182188
--title "$TAG" \
@@ -185,9 +191,9 @@ jobs:
185191
$flags
186192
- name: Assert the pre-release flag matches the version
187193
run: |
188-
actual=$(gh api "repos/$GH_REPO/releases" --paginate --jq ".[] | select(.tag_name == \"$TAG\") | .prerelease")
194+
actual=$(gh release view "$TAG" --json isPrerelease --jq .isPrerelease)
189195
if [ "$actual" != "$PRERELEASE" ]; then
190196
echo "::error::Release $TAG has prerelease=$actual, but the version requires $PRERELEASE"
191197
exit 1
192198
fi
193-
echo "Draft release $TAG has prerelease=$actual, as the version requires"
199+
echo "Release $TAG has prerelease=$actual, as the version requires"

‎RELEASE.md‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Ensure you have the following installed:
1111

1212
* `uv>=0.12.15`
1313
* A virtual environment: `uv venv`
14-
* Membership of the `libraries_admin` GitHub team, which approves publishing to PyPI
14+
* Membership of the `libraries_admin` GitHub team
1515

1616
### Prepare local environment
1717

@@ -63,7 +63,7 @@ a link to the plotly.js CHANGELOG.
6363
$ git commit -m "version changes for vX.Y.Z"
6464
$ git push
6565
```
66-
- Create a GitHub pull request from `release-X.Y.Z` to `main`, wait for CI to be green, and merge it
66+
- Create a GitHub pull request from `release-X.Y.Z` to `main`, wait for CI to be green and approval, and merge it
6767
- Create and push the tag on the merge commit on `main`. The publish workflow rejects tags that are not reachable from `main`:
6868
```sh
6969
$ git switch main && git pull
@@ -124,16 +124,34 @@ figure_widget # Figure should render in notebook
124124
125125
Once these are verified working, you can move on to publishing the release.
126126
127+
### If QA fails
128+
129+
Nothing is published until you approve the `pypi` deployment, so a problem found before that point can be fixed in place and the same version number reused.
130+
131+
1. If the run is waiting for approval, open it, choose "Review deployments", select `pypi`, and choose "Reject". The run fails, nothing is uploaded to PyPI and no GitHub release is created. (If a build or validation job already failed, there is nothing to reject.)
132+
2. Fix the problem on `main` through the normal PR process.
133+
3. Move the tag to the new tip of `main`:
134+
```sh
135+
$ git switch main && git pull
136+
$ git tag -d vX.Y.Z
137+
$ git push origin :refs/tags/vX.Y.Z
138+
$ git tag vX.Y.Z
139+
$ git push origin vX.Y.Z
140+
```
141+
4. Run the publish workflow again with the same tag and redo QA on the new `dist` artifact.
142+
143+
Once PyPI has accepted the files, the version number is taken permanently. PyPI doesn't allow a file name to be uploaded again, even after the file is deleted. If a problem is found after the upload, fix it on `main` and release a new version number.
144+
127145
### Publish the GitHub release
128146

129147
**Only members of the `libraries_admin` team can approve publishing to PyPI.**
130148

131149
1. In the workflow run, choose "Review deployments", select `pypi`, and approve. To abandon the release, reject instead; nothing is uploaded and no GitHub release is created.
132150
2. The workflow uploads the QA'd files to PyPI with trusted publishing (no API token needed).
133-
3. Only after PyPI accepts the files, the workflow creates a draft GitHub release for the tag with the same files attached and the notes copied from the version's section of `CHANGELOG.md`. The pre-release flag is set from the version (`a`, `b` and `rc` versions are pre-releases), and the workflow fails if the flag and the version disagree.
134-
4. Review the notes on the draft release, then publish it. Publishing the draft triggers nothing further.
151+
3. Only after PyPI accepts the files, the workflow creates and publishes a GitHub release for the tag with the same files attached and the notes copied from the version's section of `CHANGELOG.md`. The pre-release flag is set from the version (`a`, `b` and `rc` versions are pre-releases), and the workflow fails if the flag and the version disagree.
152+
4. Open the release and edit the notes if they need polish (for example the title and a link to the forum announcement, see "Notify Stakeholders").
135153

136-
If the upload step fails, no GitHub release is created. Fix the cause and re-run the workflow for the same tag; files already on PyPI are skipped. If the GitHub release step fails after PyPI succeeded, delete any partial draft release and re-run.
154+
If the upload step fails, no GitHub release is created. Fix the cause and re-run the workflow for the same tag; files already on PyPI are skipped. If the GitHub release step fails after PyPI succeeded, delete any partial release and re-run.
137155

138156
### Update documentation site
139157

0 commit comments

Comments
 (0)