diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 91facf4..a34c757 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,35 +1,53 @@ name: Publish to PyPI on: - release: - types: [published] + push: + tags: + - "v*" permissions: contents: read + id-token: write # Required for PyPI Trusted Publisher jobs: - publish: - name: Build and publish to PyPI + build: + name: Build distribution runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.11" - name: Install build tools - run: pip install build twine + run: pip install build - name: Build package run: python -m build - - name: Check dist - run: twine check dist/* + - name: Upload dist artifact + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + publish: + name: Publish to PyPI + needs: build + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write # Trusted Publisher OIDC + + steps: + - name: Download dist artifact + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ - name: Publish to PyPI - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - run: twine upload dist/* + uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: true