Skip to content

Commit 82a121e

Browse files
authored
Create python-publish.yml
1 parent c77e234 commit 82a121e

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# .github/workflows/python-publish.yml
2+
name: "Publish python-weaver to PyPI"
3+
4+
on:
5+
release:
6+
types: [published] # Trigger on GitHub Release publication :contentReference[oaicite:11]{index=11}
7+
8+
permissions:
9+
contents: read # Needed to fetch source code
10+
id-token: write # Enable OIDC token for Trusted Publishing :contentReference[oaicite:12]{index=12}
11+
12+
jobs:
13+
release-build:
14+
name: Build Distributions
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4 # Official checkout action :contentReference[oaicite:13]{index=13}
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5 # Official Python setup :contentReference[oaicite:14]{index=14}
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install build dependencies
27+
run: python -m pip install --upgrade pip build setuptools wheel
28+
29+
- name: Build distributions
30+
run: python -m build --sdist --wheel --outdir dist # Build both sdist & wheel :contentReference[oaicite:15]{index=15}
31+
32+
- name: Upload artifacts
33+
uses: actions/upload-artifact@v4 # Store dist/ for later steps :contentReference[oaicite:16]{index=16}
34+
with:
35+
name: release-dists
36+
path: dist/
37+
38+
pypi-publish:
39+
name: Publish to PyPI
40+
needs: release-build
41+
runs-on: ubuntu-latest
42+
43+
environment:
44+
name: pypi
45+
url: https://pypi.org/project/python-weaver/ # PyPI project URL
46+
47+
permissions:
48+
contents: read
49+
id-token: write # Mandatory for secretless publishing :contentReference[oaicite:17]{index=17}
50+
51+
steps:
52+
- name: Download artifacts
53+
uses: actions/download-artifact@v4 # Retrieve dist/ from build job :contentReference[oaicite:18]{index=18}
54+
with:
55+
name: release-dists
56+
path: dist/
57+
58+
- name: Publish distributions to PyPI
59+
uses: pypa/gh-action-pypi-publish@release/v1 # Official PyPA publish action :contentReference[oaicite:19]{index=19}
60+
with:
61+
packages-dir: dist/ # directory containing .tar.gz and .whl files :contentReference[oaicite:20]{index=20}

0 commit comments

Comments
 (0)