Skip to content

Commit de48e38

Browse files
committed
Switch from token-based to OIDC trusted publishing
Replace token-based authentication with GitHub OIDC trusted publishing for both PyPI and TestPyPI. This eliminates the need for stored API tokens in the GitHub secrets and provides better security through short-lived credentials. (cherry picked from commit c4e3208)
1 parent 782ba2a commit de48e38

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,23 @@ jobs:
8888

8989
runs-on: ubuntu-24.04
9090

91+
environment: release
92+
permissions:
93+
id-token: write
94+
9195
steps:
9296
- name: Checkout source
9397
uses: actions/checkout@v4
9498
- name: Set up Python 3.9
9599
uses: actions/setup-python@v5
96100
with:
97101
python-version: '3.9'
98-
- name: install flit
99-
run: |
100-
pip install flit~=3.4
101-
- name: Build and publish
102-
run: |
103-
flit publish
104-
env:
105-
FLIT_USERNAME: __token__
106-
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
107-
FLIT_INDEX_URL: https://upload.pypi.org/legacy/
102+
- name: Install flit
103+
run: pip install flit~=3.4
104+
- name: Build
105+
run: flit build
106+
- name: Publish to PyPI
107+
uses: pypa/gh-action-pypi-publish@release/v1
108108

109109

110110
publish-testpypi:
@@ -116,20 +116,22 @@ jobs:
116116

117117
runs-on: ubuntu-24.04
118118

119+
environment: release
120+
permissions:
121+
id-token: write
122+
119123
steps:
120124
- name: Checkout source
121125
uses: actions/checkout@v4
122126
- name: Set up Python 3.9
123127
uses: actions/setup-python@v5
124128
with:
125129
python-version: '3.9'
126-
- name: install flit
127-
run: |
128-
pip install flit~=3.4
129-
- name: Build and publish
130-
run: |
131-
flit publish
132-
env:
133-
FLIT_USERNAME: __token__
134-
FLIT_PASSWORD: ${{ secrets.TEST_PYPI_KEY }}
135-
FLIT_INDEX_URL: https://test.pypi.org/legacy/
130+
- name: Install flit
131+
run: pip install flit~=3.4
132+
- name: Build
133+
run: flit build
134+
- name: Publish to TestPyPI
135+
uses: pypa/gh-action-pypi-publish@release/v1
136+
with:
137+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)