Skip to content

Commit 2f6c68c

Browse files
committed
CI/CD: 使用推荐的发布 Action
1 parent e3a7b1a commit 2f6c68c

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,20 @@ jobs:
4343

4444
build-and-publish:
4545
runs-on: ubuntu-latest
46-
needs: test # 依赖测试通过
47-
46+
needs: test
47+
permissions:
48+
# 重要:如果使用 OIDC 发布,需要这个权限
49+
id-token: write
4850
steps:
49-
- name: Checkout code
50-
uses: actions/checkout@v4
51-
52-
- name: Install uv
53-
uses: astral-sh/setup-uv@v4
54-
55-
- name: Set up Python
56-
run: uv python install 3.13
57-
58-
- name: Install dependencies
59-
run: uv sync
51+
- uses: actions/checkout@v4
52+
- uses: astral-sh/setup-uv@v4
6053

61-
- name: Build the package
54+
- name: Build
6255
run: uv build
6356

64-
- name: Upload the package to PyPI
65-
env:
66-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
67-
run: |
68-
uv run twine upload dist/* -u __token__ -p $PYPI_TOKEN
57+
- name: Publish to PyPI
58+
# 使用官方专用的 Action
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
with:
61+
# 如果你在 PyPI 开启了 Trusted Publishing,甚至不需要配置 TOKEN
62+
password: ${{ secrets.PYPI_TOKEN }}

0 commit comments

Comments
 (0)