From 1014c7ee0c211c16cff1bc04b3bee12d0f6c9cab Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 17 Nov 2026 08:32:28 +0100 Subject: [PATCH] ci: publish to PyPI with trusted publishing and attestations Release the package the same way as the npm package: authenticate to PyPI through Trusted Publishing (OIDC) from the `release` environment instead of a long-lived API token, and upload PEP 740 attestations so PyPI shows the release provenance. Building and publishing are split into separate jobs so the build tooling never runs with the id-token permission. Refs TINY-878 --- .github/workflows/ci-cd.yml | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 4735108..71af750 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -79,7 +79,7 @@ jobs: run: | pytest test/integration.py - Publish: + Build: if: | github.repository == 'tinify/tinify-python' && startsWith(github.ref, 'refs/tags') && @@ -121,12 +121,33 @@ jobs: run: | python -m venv wheel_env ./wheel_env/bin/pip install dist/tinify*.whl + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + if-no-files-found: error + + Publish: + timeout-minutes: 10 + needs: [Build] + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/project/tinify/${{ github.ref_name }}/ + permissions: + id-token: write + steps: + - name: Download the distribution packages + uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.PYPI_ACCESS_TOKEN }} # Use the test repository for testing the publish feature - # repository_url: https://test.pypi.org/legacy/ - packages_dir: dist/ - print_hash: true + # repository-url: https://test.pypi.org/legacy/ + packages-dir: dist/ + attestations: true + print-hash: true