Skip to content

Commit 32f67a2

Browse files
Add GitHub Actions workflow for publishing to PyPI
This workflow automates the publishing of Python packages to PyPI upon tagging a version. It includes steps for building distribution artifacts and uploading them.
1 parent 5656103 commit 32f67a2

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
env:
14+
PYTHONUTF8: "1"
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.12"
24+
cache: "pip"
25+
cache-dependency-path: |
26+
pyproject.toml
27+
28+
- name: Build distribution artifacts
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install build
32+
python -m build
33+
34+
- name: Upload distribution artifacts
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: python-package-distributions
38+
path: dist/
39+
40+
publish-pypi:
41+
runs-on: ubuntu-latest
42+
needs: build
43+
44+
permissions:
45+
id-token: write
46+
47+
environment:
48+
name: pypi
49+
50+
steps:
51+
- name: Download distribution artifacts
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
- name: Publish to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)