Release & Publish 🐍 #17
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 to PyPI 🐍 | |
| on: | |
| release: | |
| types: [published] # Triggers when you click "Publish Release" on GitHub | |
| workflow_dispatch: | |
| jobs: | |
| build-and-publish: | |
| name: Build & Publish | |
| runs-on: ubuntu-latest | |
| # Permission needed for the publishing action to work | |
| permissions: | |
| id-token: write # IMPORTANT: This is required for trusted publishing | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build | |
| - name: Build package | |
| run: python -m build | |
| # This creates the 'dist/' folder at the root | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| # It automatically looks in 'dist/', so we don't need to specify paths! |