Skip to content

ci(sdk): publish the Python SDK to PyPI via trusted publishing - #1087

Merged
rmyndharis merged 1 commit into
mainfrom
ci/python-sdk-trusted-publishing
Aug 6, 2026
Merged

ci(sdk): publish the Python SDK to PyPI via trusted publishing#1087
rmyndharis merged 1 commit into
mainfrom
ci/python-sdk-trusted-publishing

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

rmyndharis-openwa reached PyPI once, manually, and has sat at 0.1.0 since. This adds a tag-triggered publish workflow matching js-sdk-release.yml.

Change

Authentication is PyPI Trusted Publishing (OIDC). No PyPI token exists in the workflow or in repository secrets — PyPI mints a short-lived credential from the GitHub OIDC token, so nothing long-lived exists to leak or rotate.

Details worth reviewing:

  • The version guard reads pyproject.toml textually, not with tomllib. The guard runs before setup-python so it must not depend on an interpreter being present, and tomllib would rule out the 3.9 this package still supports. The Java and JavaScript guards are textual for the same reason. Verified against the real file: it extracts 0.1.0.
  • One build interpreter, not the CI matrix. The wheel is pure Python (py3-none-any) and carries requires-python from the metadata, so the build interpreter cannot shape the artifact, and the 3.9/3.12 compatibility matrix already runs on every push to main. The suite still re-runs here so the uploaded artifacts are the ones it passed against.
  • Guards run before anything is built. workflow_dispatch is restricted to the same py-sdk-v* tag shape a push triggers on, so an arbitrary branch or a monorepo v* app tag cannot reach PyPI, and the tag version must match pyproject.toml.
  • pypa/gh-action-pypi-publish is pinned to the commit SHA behind v1.14.2, matching how every other third-party action in this repository is pinned. Note the release ref is an annotated tag, so the tag object's SHA is not the commit SHA — the pin dereferences to the commit.

One-time setup required before the first tag

The pypi.org side cannot be automated. In the project's publishing settings, add a GitHub trusted publisher: owner rmyndharis, repository OpenWA, workflow python-sdk-release.yml. Until that exists PyPI rejects the upload. Documented in sdk/python/README.md -> Releasing.

No repository secrets are needed.

rmyndharis-openwa reached PyPI once, manually, and has sat at 0.1.0 since. Add
a tag-triggered workflow matching js-sdk-release.yml.

Authentication is PyPI Trusted Publishing (OIDC): no token in the workflow or
in repository secrets, because PyPI mints a short-lived credential from the
GitHub OIDC token.

The version guard reads pyproject.toml textually rather than with tomllib. The
guard runs before setup-python so it must not depend on an interpreter, and
tomllib would rule out the 3.9 the package still supports — the sibling guards
in the Java and JavaScript releases are textual for the same reason.

Publishing builds on a single interpreter: the wheel is pure Python and carries
requires-python from the metadata, so the build interpreter cannot shape the
artifact, and the 3.9/3.12 compatibility matrix already runs on every push to
main. The suite still re-runs here so the uploaded artifacts are the ones it
passed against.

The pypi.org trusted-publisher entry is a one-time manual step, documented in
sdk/python/README.md -> Releasing.
@rmyndharis
rmyndharis force-pushed the ci/python-sdk-trusted-publishing branch from 872ecac to 8a25b34 Compare August 6, 2026 03:16
@rmyndharis
rmyndharis merged commit 30d5188 into main Aug 6, 2026
13 checks passed
@rmyndharis
rmyndharis deleted the ci/python-sdk-trusted-publishing branch August 6, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant