Skip to content

Commit 31a5af6

Browse files
authored
Add GitHub Actions workflow for PyPI release
1 parent 33753e0 commit 31a5af6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # 例如 v0.1.1
7+
workflow_dispatch: {} # 允许手动触发
8+
9+
jobs:
10+
build-and-upload-pypi:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out repo
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Upgrade build tools
23+
run: python -m pip install --upgrade pip build twine
24+
25+
- name: Build wheel and sdist
26+
run: python -m build
27+
28+
- name: Twine check
29+
run: python -m twine check dist/*
30+
31+
- name: Upload to PyPI
32+
env:
33+
TWINE_USERNAME: __token__
34+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
35+
run: python -m twine upload dist/*

0 commit comments

Comments
 (0)