Skip to content

Commit 1575f30

Browse files
ci: publish via trusted-publishing
1 parent 6232ae4 commit 1575f30

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

.github/workflows/publish.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
4-
name: Upload Python Package
1+
# use PyPI trusted publishing, as described here:
2+
# https://blog.trailofbits.com/2023/05/23/trusted-publishing-a-new-benchmark-for-packaging-security/
3+
name: publish to pypi
54

65
on:
76
release:
8-
types: [created]
7+
types: [published]
98

10-
jobs:
11-
deploy:
9+
permissions:
10+
contents: write
1211

12+
jobs:
13+
pypi-publish:
1314
runs-on: ubuntu-latest
14-
15+
environment:
16+
name: release
17+
permissions:
18+
id-token: write
1519
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Python
18-
uses: actions/setup-python@v2
19-
with:
20-
python-version: '3.x'
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine
25-
- name: Build and publish
26-
env:
27-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29-
run: |
30-
python setup.py sdist bdist_wheel
31-
twine upload dist/*
20+
- uses: actions/checkout@v2
21+
- uses: astral-sh/setup-uv@v5
22+
- name: install
23+
run: uv sync --all-extras
24+
- name: build package
25+
run: uv run python -m build
26+
- name: upload package artifacts
27+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
28+
with:
29+
path: dist/*
30+
- name: publish package
31+
uses: pypa/gh-action-pypi-publish@f5622bde02b04381239da3573277701ceca8f6a0 # release/v1
32+
with:
33+
skip-existing: true
34+
verbose: true
35+
print-hash: true

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@ length_sort = true
7272

7373
[tool.ruff]
7474
line-length = 120
75+
76+
[dependency-groups]
77+
build = [
78+
"build>=1.2.2.post1",
79+
]

0 commit comments

Comments
 (0)