v0.1.0 #2
Workflow file for this run
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 | |
| on: | |
| release: | |
| branches: | |
| - main | |
| types: | |
| - published | |
| workflow_dispatch: | |
| inputs: | |
| repository: | |
| description: "Target package index" | |
| required: true | |
| default: testpypi | |
| type: choice | |
| options: | |
| - testpypi | |
| - pypi | |
| permissions: | |
| id-token: write | |
| attestations: write | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| artifact-name: python-package-distributions | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Build distributions | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build twine | |
| python -m build | |
| python -m twine check dist/* | |
| - name: Upload distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/* | |
| - name: Create attestations | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-path: "dist/*" | |
| publish-testpypi: | |
| if: github.event_name == 'workflow_dispatch' && inputs.repository == 'testpypi' | |
| needs: build | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Download distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist | |
| - name: Publish package to TestPyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} | |
| run: python -m pip install --upgrade twine && python -m twine upload --repository testpypi dist/* | |
| publish-pypi: | |
| if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.repository == 'pypi') | |
| needs: build | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Download distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist | |
| - name: Publish package to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: python -m pip install --upgrade twine && python -m twine upload dist/* |