Publish Python package to PyPI #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Python package to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| id-token: write # REQUIRED for PyPI Trusted Publishing (OIDC) | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Install build tooling | |
| run: python -m pip install --upgrade pip build | |
| - name: Build sdist and wheel | |
| run: python -m build | |
| - name: Publish to PyPI (Trusted Publishing) | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| # For trusted publishing, you typically do NOT set username/password. | |
| # If you are publishing to TestPyPI instead, you can set repository-url. | |
| # repository-url: https://test.pypi.org/legacy/ | |
| verbose: true |