Skip to content

Commit 93f6519

Browse files
fix(publish): switch to OIDC trusted publisher (pypa/gh-action-pypi-publish), removes PYPI_API_TOKEN dependency
1 parent 5a4798b commit 93f6519

1 file changed

Lines changed: 11 additions & 30 deletions

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,32 @@ on:
44
release:
55
types: [published]
66
workflow_dispatch:
7-
inputs:
8-
pypi_target:
9-
description: 'PyPI target (pypi or testpypi)'
10-
default: 'testpypi'
11-
type: choice
12-
options:
13-
- pypi
14-
- testpypi
157

168
jobs:
17-
build-and-publish:
9+
publish:
1810
runs-on: ubuntu-latest
11+
environment: pypi
1912
permissions:
20-
contents: read
2113
id-token: write
2214

2315
steps:
2416
- uses: actions/checkout@v4
2517

26-
- name: Set up Python 3.11
18+
- name: Set up Python
2719
uses: actions/setup-python@v5
2820
with:
29-
python-version: "3.11"
21+
python-version: "3.12"
3022

31-
- name: Install build deps
23+
- name: Install dependencies
3224
run: |
25+
python -m pip install --upgrade pip
3326
pip install build twine
3427
3528
- name: Build package
36-
run: |
37-
python -m build
38-
39-
- name: Publish to PyPI
40-
if: ${{ inputs.pypi_target != 'testpypi' || github.event_name == 'release' }}
41-
env:
42-
TWINE_USERNAME: __token__
43-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
44-
run: |
45-
twine upload dist/* --verbose
29+
run: python -m build
4630

47-
- name: Publish to TestPyPI
48-
if: ${{ inputs.pypi_target == 'testpypi' }}
49-
env:
50-
TWINE_USERNAME: __token__
51-
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
52-
run: |
53-
twine upload --repository testpypi dist/* --verbose
31+
- name: Check package
32+
run: twine check dist/*
5433

34+
- name: Publish to PyPI
35+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)