File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed
Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Publish Python Package to PyPI and GitHub Releases
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+
8+ jobs :
9+ publish :
10+ name : Build and Publish with uv
11+ runs-on : ubuntu-latest
12+ permissions :
13+ # 允许工作流从 GitHub 获取 OIDC token
14+ id-token : write
15+ # 允许工作流创建 GitHub Release 并上传构建产物
16+ contents : write
17+
18+ steps :
19+ # 检出代码
20+ - name : Checkout repository
21+ uses : actions/checkout@v4
22+ with :
23+ # 必需:拉取所有 Git 历史记录。
24+ # 这是 setuptools-scm 能够根据 tag 准确计算出版本号的前提。
25+ fetch-depth : 0
26+
27+ # 设置 Python 环境
28+ - name : Set up Python
29+ uses : actions/setup-python@v5
30+ with :
31+ python-version : ' 3.11'
32+
33+ # 安装 uv
34+ - name : Install uv
35+ run : |
36+ curl -LsSf https://astral.sh/uv/install.sh | sh
37+ echo "$HOME/.cargo/bin" >> $GITHUB_PATH
38+ shell : bash
39+
40+ # 使用 uv 构建项目
41+ - name : Build with uv
42+ run : uv build --sdist --wheel --no-sources
43+ shell : bash
44+ env :
45+ SETUPTOOLS_SCM_PRETEND_VERSION : ${{ github.ref_name }}
46+
47+ # 创建 GitHub Release
48+ - name : Create GitHub Release
49+ uses : softprops/action-gh-release@v2
50+ with :
51+ name : Release ${{ github.ref_name }}
52+ tag_name : ${{ github.ref }}
53+ files : dist/*
54+ draft : false
55+ prerelease : false
56+
57+ # 使用 uv 将包发布到 PyPI
58+ - name : Publish to PyPI with uv
59+ run : uv publish dist/*
60+ shell : bash
You can’t perform that action at this time.
0 commit comments