Skip to content

Commit d03f43e

Browse files
committed
Add a release workflow to publish to PyPI
This uses the new Trusted Publisher setup to automatically publish when a release is published.
1 parent 44e80c8 commit d03f43e

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Diff for: .github/workflows/release.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
3+
name: Release
4+
on:
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
build:
11+
name: Build Release Packages
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 10
17+
18+
- name: Get tags
19+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
20+
21+
- name: Set up Python
22+
id: setup
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: 3.x
26+
27+
- name: Install build tools
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install --upgrade build
31+
32+
- name: Build packages
33+
run: python -m build
34+
35+
- name: Save built packages as artifact
36+
uses: actions/upload-artifact@v3
37+
with:
38+
name: packages-${{ runner.os }}-${{ steps.setup.outputs.python-version }}
39+
path: dist/
40+
if-no-files-found: error
41+
retention-days: 5
42+
43+
publish:
44+
name: Upload release to PyPI
45+
needs: build
46+
runs-on: ubuntu-latest
47+
environment: release
48+
permissions:
49+
id-token: write
50+
steps:
51+
- name: Download packages
52+
uses: actions/download-artifact@v3
53+
54+
- name: Consolidate packages for upload
55+
run: |
56+
mkdir dist
57+
cp packages-*/* dist/
58+
59+
- name: Publish package distributions to PyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)