Skip to content

Commit baef197

Browse files
Update publish.yml to use Trusted Publishers
1 parent 2484916 commit baef197

File tree

1 file changed

+64
-31
lines changed

1 file changed

+64
-31
lines changed

.github/workflows/publish.yml

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,70 @@ on:
44
release:
55
types: [published]
66

7-
permissions:
8-
contents: read
9-
107
jobs:
11-
publish:
12-
runs-on: ubuntu-22.04
8+
build:
9+
name: Build distribution
10+
runs-on: ubuntu-24.04
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python 3.9
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.9"
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install build
25+
26+
- name: Build package
27+
run: python -m build
28+
29+
- name: Store distribution packages
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: python-package-distributions
33+
path: dist/
34+
35+
publish-to-testpypi:
36+
name: Publish to TestPyPI
37+
runs-on: ubuntu-24.04
38+
needs: build
39+
environment:
40+
name: testpypi
41+
url: https://test.pypi.org/p/frouros
42+
permissions:
43+
id-token: write
44+
45+
steps:
46+
- name: Download distribution packages
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: python-package-distributions
50+
path: dist/
51+
- name: Publish distribution to TestPyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
53+
with:
54+
repository-url: https://test.pypi.org/legacy/
55+
56+
publish-to-pypi:
57+
name: Publish to PyPI
58+
runs-on: ubuntu-24.04
59+
needs: [build, publish-to-testpypi]
60+
environment:
61+
name: pypi
62+
url: https://pypi.org/p/frouros
63+
permissions:
64+
id-token: write
1365

1466
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v4
17-
18-
- name: Set up Python 3.9
19-
uses: actions/setup-python@v5
20-
with:
21-
python-version: "3.9"
22-
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install build
27-
28-
- name: Build package
29-
run: python -m build
30-
31-
- name: Publish to Test PyPI
32-
uses: pypa/gh-action-pypi-publish@release/v1
33-
with:
34-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
35-
repository-url: https://test.pypi.org/legacy/
36-
37-
- name: Publish to PyPI
38-
uses: pypa/gh-action-pypi-publish@release/v1
39-
with:
40-
password: ${{ secrets.PYPI_API_TOKEN }}
67+
- name: Download distribution packages
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
- name: Publish distribution to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)