Skip to content

Commit aa273e3

Browse files
authored
🔧 Switch PyPI publishing to trusted publishing (OIDC) (#1140)
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 49be3ab commit aa273e3

1 file changed

Lines changed: 22 additions & 28 deletions

File tree

.github/workflows/tests.yml

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -126,49 +126,43 @@ jobs:
126126

127127
publish:
128128

129-
name: Publish myst-parser to PyPi
129+
name: Publish myst-parser to PyPI
130130
needs:
131131
- check
132132
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
133133
runs-on: ubuntu-latest
134+
permissions:
135+
id-token: write
136+
environment:
137+
name: pypi
138+
url: https://pypi.org/p/myst-parser
134139
steps:
135-
- name: Checkout source
136-
uses: actions/checkout@v6
137-
- name: Set up Python 3.11
138-
uses: actions/setup-python@v6
140+
- uses: actions/checkout@v6
141+
- uses: actions/setup-python@v6
139142
with:
140143
python-version: "3.11"
141-
- name: install flit
142-
run: |
143-
pip install flit~=3.4
144-
- name: Build and publish
145-
run: |
146-
flit publish
147-
env:
148-
FLIT_USERNAME: __token__
149-
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
144+
- run: pip install flit~=3.4
145+
- run: flit build
146+
- uses: pypa/gh-action-pypi-publish@release/v1
150147

151148
publish-docutils:
152149

153-
name: Publish myst-docutils to PyPi
150+
name: Publish myst-docutils to PyPI
154151
needs: [publish]
155152
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
156153
runs-on: ubuntu-latest
154+
permissions:
155+
id-token: write
156+
environment:
157+
name: pypi
158+
url: https://pypi.org/p/myst-docutils
157159
steps:
158-
- name: Checkout source
159-
uses: actions/checkout@v6
160-
- name: Set up Python 3.11
161-
uses: actions/setup-python@v6
160+
- uses: actions/checkout@v6
161+
- uses: actions/setup-python@v6
162162
with:
163163
python-version: "3.11"
164-
- name: install flit and tomlkit
165-
run: |
166-
pip install flit~=3.4 tomlkit
164+
- run: pip install flit~=3.4 tomlkit
167165
- name: Modify setup
168166
run: python .github/workflows/docutils_setup.py pyproject.toml README.md
169-
- name: Build and publish
170-
run: |
171-
flit publish
172-
env:
173-
FLIT_USERNAME: __token__
174-
FLIT_PASSWORD: ${{ secrets.PYPI_KEY_DOCUTILS }}
167+
- run: flit build
168+
- uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)