Publish to PyPI #22
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: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: ["Run auto tagging"] | |
| types: [completed] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Check current version | |
| run: | | |
| echo "Current version in pyproject.toml:" | |
| grep "version =" pyproject.toml | |
| echo "Current version in _version.py:" | |
| cat _version.py | |
| - name: Build package | |
| run: | | |
| echo "Building package..." | |
| python -m build | |
| echo "Built files:" | |
| ls -la dist/ | |
| - name: Check distribution | |
| run: | | |
| twine check dist/* | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| run: | | |
| echo "Publishing to PyPI..." | |
| twine upload dist/* |