python-publish #32
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: python-publish | |
| on: | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| workflow_call: | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish: | |
| if: | | |
| (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'python/')) || | |
| (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') || | |
| (github.event_name == 'workflow_call') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install uv | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install dependencies | |
| run: | | |
| make install | |
| uv pip install build | |
| working-directory: python | |
| - name: Copy README.md | |
| run: | | |
| cp README.md python/README.md | |
| - name: Build package | |
| run: uv run python -m build | |
| working-directory: python | |
| # Sanity check | |
| - name: Run tests | |
| run: | | |
| uv run pytest tests | |
| working-directory: python | |
| - name: Publish package | |
| uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | |
| with: | |
| packages_dir: python/dist/ | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} |