From e5d37c49994dfb13064386b416b322e0188a93e5 Mon Sep 17 00:00:00 2001 From: William Schmitt Date: Tue, 17 Nov 2026 12:49:52 -0800 Subject: [PATCH] ci: publish to PyPI with trusted publishing (CB-0) PYPI_TOKEN was a long-lived repo secret (2025-09-05) readable by any workflow on any branch, so any of the repo's writers could publish to PyPI without the `release` environment approval. PyPI releases also carried no provenance (integrity API: "No provenance available" for 1.26.0). Publish now builds with uv and uploads through pypa/gh-action-pypi-publish, which uses the job's OIDC token and uploads PEP 740 attestations. The trusted publisher on PyPI must be pinned to workflow publish-pypi.yml and environment `release`, so only an approved run from main or a v* tag can publish. Drops bin/publish-pypi and the PYPI_TOKEN release-doctor check. Delete the PYPI_TOKEN secret and revoke the token on PyPI once a release succeeds. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish-pypi.yml | 13 ++++++++----- .github/workflows/release-doctor.yml | 1 - CONTRIBUTING.md | 7 +------ bin/check-release-environment | 4 ---- bin/publish-pypi | 7 ------- 5 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 bin/publish-pypi diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index afe421e9..a6e85313 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -17,6 +17,9 @@ jobs: if: github.repository == 'browserbase/sdk-python' environment: release runs-on: ubuntu-latest + permissions: + contents: read + id-token: write steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -26,8 +29,8 @@ jobs: with: version: '0.9.13' - - name: Publish to PyPI - run: | - bash ./bin/publish-pypi - env: - PYPI_TOKEN: ${{ secrets.BROWSERBASE_PYPI_TOKEN || secrets.PYPI_TOKEN }} + - name: Build + run: uv build + + # Trusted publishing (OIDC) with attestations; no stored PyPI token. + - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 32cc46c8..b77d60ca 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -20,4 +20,3 @@ jobs: env: STLC_BOT_APP_ID: ${{ secrets.STLC_BOT_APP_ID }} STLC_BOT_PRIVATE_KEY: ${{ secrets.STLC_BOT_PRIVATE_KEY }} - PYPI_TOKEN: ${{ secrets.BROWSERBASE_PYPI_TOKEN || secrets.PYPI_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4fdd0cee..9f6fb32b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -119,9 +119,4 @@ the changes aren't made through the automated pipeline, you may want to make rel ### Publish with a GitHub workflow -You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/browserbase/sdk-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up. - -### Publish manually - -If you need to manually release a package, you can run the `bin/publish-pypi` script with a `PYPI_TOKEN` set on -the environment. +You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/browserbase/sdk-python/actions/workflows/publish-pypi.yml). It publishes through PyPI trusted publishing and needs a `release` environment approval; there is no manual publish path. diff --git a/bin/check-release-environment b/bin/check-release-environment index 584d2a63..5e9d64b3 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -8,10 +8,6 @@ if [ -z "${STLC_BOT_APP_ID}" ] || [ -z "${STLC_BOT_PRIVATE_KEY}" ]; then errors+=("The STLC_BOT_APP_ID / STLC_BOT_PRIVATE_KEY secrets are not set. Releases mint tokens from the browserbase-stlc-bot GitHub App; check the org secrets' repository access.") fi -if [ -z "${PYPI_TOKEN}" ]; then - errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.") -fi - lenErrors=${#errors[@]} if [[ lenErrors -gt 0 ]]; then diff --git a/bin/publish-pypi b/bin/publish-pypi deleted file mode 100644 index e72ca2fa..00000000 --- a/bin/publish-pypi +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -eux -rm -rf dist -mkdir -p dist -uv build -uv publish --token=$PYPI_TOKEN