Deploy to Godot #11
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: Deploy to PyPI | |
| on: | |
| issues: | |
| types: [opened, labeled] | |
| jobs: | |
| deploy: | |
| name: Release to PyPI | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event.issue.title == 'Deploy to PyPI' && | |
| contains(github.event.issue.labels.*.name, 'CI') | |
| permissions: | |
| contents: write | |
| issues: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Validate release secrets | |
| run: | | |
| required=( | |
| PYPI_API_TOKEN | |
| ) | |
| for name in "${required[@]}"; do | |
| if [ -z "${!name}" ]; then | |
| echo "ERROR: Missing required secret: $name" | |
| exit 1 | |
| fi | |
| done | |
| env: | |
| PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
| - name: Install build tools | |
| run: pip install build twine | |
| - name: Build distribution | |
| working-directory: python | |
| run: python -m build | |
| - name: Publish to PyPI | |
| working-directory: python | |
| run: twine upload dist/* --non-interactive | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| - name: Comment on issue with result | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const success = '${{ job.status }}' === 'success'; | |
| const body = success | |
| ? `Deployment succeeded. \`qti-neon\` has been published to PyPI.` | |
| : `Deployment failed. Check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.`; | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body | |
| }); |