Skip to content

Commit 0e75772

Browse files
feat(workflow): create publish-tag-to-pypi.yaml to support automatic publish
1 parent 6807014 commit 0e75772

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish Tag to PyPI
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
persist-credentials: false
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.x"
16+
- name: Install build tool
17+
run: python3 -m pip install build --user
18+
- name: Build wheel and source distribution
19+
run: python3 -m build
20+
- name: Upload distributables as artifact
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: python-package-distributions
24+
path: dist/
25+
26+
publish-to-pypi:
27+
needs: build
28+
if: startsWith(github.ref, 'refs/tags/')
29+
runs-on: ubuntu-latest
30+
environment:
31+
name: pypi
32+
steps:
33+
- name: Download distributables
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: python-package-distributions
37+
path: dist/
38+
39+
- name: Install Twine
40+
run: python3 -m pip install --user twine
41+
42+
- name: Publish to PyPI
43+
env:
44+
TWINE_USERNAME: __token__
45+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
46+
run: |
47+
python3 -m twine upload dist/*

0 commit comments

Comments
 (0)