Professionalize docs/workflows: PyPI install, dev guide, branch strat… #6
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 Package | ||
|
Check failure on line 1 in .github/workflows/publish.yml
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
| inputs: | ||
| publish: | ||
| description: "Publish dist to PyPI after build (true/false)" | ||
| required: false | ||
| default: "false" | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| build: | ||
| name: Build distribution | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
| cache: pip | ||
| - name: Install build tooling | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install build twine | ||
| - name: Build package | ||
| run: python -m build | ||
| - name: Verify package metadata | ||
| run: python -m twine check dist/* | ||
| - name: Upload dist artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/* | ||
| publish: | ||
| name: Publish to PyPI | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish == 'true') | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - name: Download dist artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist | ||
| - name: Publish package to PyPI (token) | ||
| if: ${{ secrets.PYPI_API_TOKEN != '' }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| user: __token__ | ||
| password: ${{ secrets.PYPI_API_TOKEN }} | ||
| - name: Publish package to PyPI (trusted publishing) | ||
| if: ${{ secrets.PYPI_API_TOKEN == '' }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||