Skip to content

Commit 7dbbef9

Browse files
committed
ci(pypi): Split test and publish jobs, per pypa action docs
1 parent d672326 commit 7dbbef9

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

.github/workflows/publish.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
11
name: Publish to PyPI
22
on: push
33
jobs:
4-
publish:
4+
build:
5+
permissions:
6+
contents: read
57
runs-on: ubuntu-latest
68
steps:
79
- uses: actions/checkout@v4
810
- uses: actions/setup-python@v5
911
with:
10-
python-version: 3.8
12+
python-version: '3.10'
1113
- run: pip install --upgrade build
1214
- run: python -m build --sdist --wheel
13-
- name: Publish to TestPyPI
14-
uses: pypa/gh-action-pypi-publish@release/v1
15+
- uses: actions/upload-artifact@v4
16+
with:
17+
name: python-package-distributions
18+
path: dist/
19+
test:
20+
needs: build
21+
permissions:
22+
id-token: write
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/download-artifact@v5
26+
with:
27+
name: python-package-distributions
28+
path: dist/
29+
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
1530
with:
16-
password: ${{ secrets.TEST_PYPI_TOKEN }}
1731
repository-url: https://test.pypi.org/legacy/
1832
skip-existing: true
19-
- name: Publish to PyPI
20-
if: startsWith(github.ref, 'refs/tags')
21-
uses: pypa/gh-action-pypi-publish@release/v1
33+
publish:
34+
if: startsWith(github.ref, 'refs/tags/')
35+
needs: test
36+
permissions:
37+
id-token: write
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/download-artifact@v5
2241
with:
23-
password: ${{ secrets.PYPI_TOKEN }}
42+
name: python-package-distributions
43+
path: dist/
44+
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

0 commit comments

Comments
 (0)