Skip to content

Commit 2c3f71e

Browse files
authored
🔧 Switch PyPI publishing to trusted publishing (OIDC) (#397)
Replace long-lived API token with PyPI trusted publishing via pypa/gh-action-pypi-publish. This uses short-lived OIDC credentials scoped to the CI workflow, eliminating the need for stored secrets.
1 parent 36c5f54 commit 2c3f71e

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

.github/workflows/tests.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,23 @@ jobs:
112112

113113
publish:
114114

115-
name: Publish to PyPi
115+
name: Publish to PyPI
116116
needs: [pre-commit, tests]
117117
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
118118
runs-on: ubuntu-latest
119+
permissions:
120+
id-token: write
121+
environment:
122+
name: pypi
123+
url: https://pypi.org/p/markdown-it-py
119124
steps:
120-
- name: Checkout source
121-
uses: actions/checkout@v4
122-
- name: Set up Python
123-
uses: actions/setup-python@v5
125+
- uses: actions/checkout@v4
126+
- uses: actions/setup-python@v5
124127
with:
125128
python-version: '3.10'
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.PYPI_KEY }}
129+
- run: pip install flit~=3.4
130+
- run: flit build
131+
- uses: pypa/gh-action-pypi-publish@release/v1
135132

136133
allgood:
137134
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)