Skip to content

Commit 3ee0c88

Browse files
committed
chore: release to pypi via trusted publisher
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 518c37a commit 3ee0c88

1 file changed

Lines changed: 65 additions & 19 deletions

File tree

.github/workflows/pypi-release.yml

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,69 @@ on:
66
tags:
77
- "v*.*.*"
88

9-
jobs:
10-
build-and-publish-to-pypi:
11-
name: Build and publish library to PyPI
12-
runs-on: ubuntu-22.04
9+
build-pypi-distribs:
10+
name: Build for publishing
11+
runs-on: ubuntu-24.04
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
- name: Set up Python
18+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
19+
with:
20+
python-version: 3.10
21+
22+
- name: Install pypa/build
23+
run: python -m pip install build --user
24+
25+
- name: Build a binary wheel and a source tarball
26+
run: python -m build --sdist --wheel --outdir dist/
27+
28+
- name: Upload built archives
29+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
30+
with:
31+
name: pypi_archives
32+
path: dist/*
33+
34+
create-gh-release:
35+
name: Create GH release
36+
needs:
37+
- build-pypi-distribs
38+
runs-on: ubuntu-24.04
39+
40+
steps:
41+
- name: Download built archives
42+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
43+
with:
44+
name: pypi_archives
45+
path: dist
46+
47+
- name: Create GH release
48+
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
49+
with:
50+
draft: false
51+
generate_release_notes: true
52+
files: dist/*
53+
54+
create-pypi-release:
55+
name: Create PyPI release
56+
needs:
57+
- create-gh-release
58+
runs-on: ubuntu-24.04
59+
environment: pypi-publish
60+
permissions:
61+
id-token: write
62+
1363
steps:
14-
- uses: actions/checkout@v4
15-
- name: Set up Python
16-
uses: actions/setup-python@v5
17-
with:
18-
python-version: 3.9
19-
- name: Install pypa/build
20-
run: python -m pip install build --user
21-
- name: Build a binary wheel and a source tarball
22-
run: python -m build --sdist --wheel --outdir dist/
23-
- name: Publish distribution to PyPI
24-
if: startsWith(github.ref, 'refs/tags')
25-
uses: pypa/gh-action-pypi-publish@release/v1
26-
with:
27-
password: ${{ secrets.PYPI_API_TOKEN }}
28-
64+
- name: Download built archives
65+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
66+
with:
67+
name: pypi_archives
68+
path: dist
69+
70+
- name: Publish to PyPI
71+
if: startsWith(github.ref, 'refs/tags/')
72+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
73+
with:
74+
verbose: true

0 commit comments

Comments
 (0)