Skip to content

Commit d8cfc7d

Browse files
committed
workflows: automatically publish releases to PyPI
Use PyPI's trusted publisher mechanism, which is configured to require deploying via a GitHub environment, which is configured to require manual approval. Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent 6ac708e commit d8cfc7d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.github/ISSUE_TEMPLATE/release.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
- [ ] Update `CHANGELOG.md` and version in `openslide/_version.py`
44
- [ ] Create and push signed tag
5-
- [ ] `git clean -dxf && mkdir dist`
6-
- [ ] Find the [workflow run](https://github.com/openslide/openslide-python/actions/workflows/python.yml) for the tag; download its dist and docs artifacts
7-
- [ ] `unzip /path/to/downloaded/openslide-python-dist.zip && mv openslide-python-dist-*/* dist/`
8-
- [ ] `twine upload dist/*`
5+
- [ ] Find the [workflow run](https://github.com/openslide/openslide-python/actions/workflows/python.yml) for the tag
6+
- [ ] Once the build finishes, approve deployment to PyPI
7+
- [ ] Download the docs artifact
8+
- [ ] Verify that the workflow created a [PyPI release](https://pypi.org/p/openslide-python) with a description, source tarball, and wheels
99
- [ ] Verify that the workflow created a [GitHub release](https://github.com/openslide/openslide-python/releases) with release notes, a source tarball, and wheels
1010
- [ ] `cd` into website checkout; `rm -r api/python && unzip /path/to/downloaded/openslide-python-docs.zip && mv openslide-python-docs-* api/python`
1111
- [ ] Update website: `_data/releases.yaml`, `_includes/news.md`

.github/workflows/python.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,24 @@ jobs:
222222
release:
223223
name: Release
224224
if: github.ref_type == 'tag'
225+
environment:
226+
name: pypi
227+
url: https://pypi.org/p/openslide-python
225228
needs: [pre-commit, tests, windows]
226229
runs-on: ubuntu-latest
227230
concurrency: release-${{ github.ref }}
228231
permissions:
229232
contents: write
233+
id-token: write
230234
steps:
231235
- name: Download artifacts
232236
uses: actions/download-artifact@v3
233237
with:
234238
name: ${{ needs.pre-commit.outputs.dist-base }}
239+
- name: Release to PyPI
240+
uses: pypa/gh-action-pypi-publish@release/v1
241+
with:
242+
packages-dir: ${{ needs.pre-commit.outputs.dist-base }}
235243
- name: Release to GitHub
236244
env:
237245
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)