PyPI Publishing Setup
PyPI Publishing Setup
This document covers the one-time setup required to enable automated publishing of the connexity-cli package to PyPI.
Overview
The publishing pipeline uses two GitHub Actions workflows:
-
Release Please (
.github/workflows/release-please.yml) — Watches merges tomainthat touchbackend/cli/or the rootpyproject.toml. Automatically opens and maintains a Release PR with changelog and version bumps. When merged, creates a git tag and GitHub Release. -
Publish to PyPI (
.github/workflows/publish-pypi.yml) — Triggered bycli-v*tags (component-prefixed so they don't collide with the platform's plainv*tags). Builds the wheel, validates it, publishes to PyPI via Trusted Publisher (OIDC), and runs a post-publish smoke test.
Tag namespaces in this repo
cli-vX.Y.Z— CLI package release (this doc)vX.Y.Z— platform release, seeplatform-releases.mdv0.1.0(no prefix) — historical CLI release predating the namespace split; do not reuse.
One-Time Setup: PyPI Trusted Publisher
Trusted Publishers use OpenID Connect (OIDC) so the GitHub Actions workflow can publish to PyPI without storing API tokens as secrets.
Steps
-
Go to pypi.org and log in (or create an account).
-
For a new package (first-ever publish):
- Go to https://pypi.org/manage/account/publishing/
- Under "Add a new pending publisher", fill in:
- PyPI project name:
connexity-cli - Owner:
Connexity-AI - Repository:
connexity - Workflow name:
publish-pypi.yml - Environment name:
pypi
- PyPI project name:
- Click "Add"
-
For an existing package (already uploaded at least once):
- Go to https://pypi.org/manage/project/connexity-cli/settings/publishing/
- Under "Add a new publisher", fill in the same fields as above
- Click "Add"
GitHub Environment Setup
The publish workflow references a GitHub environment called pypi. Create it:
- Go to https://github.com/Connexity-AI/connexity/settings/environments
- Click "New environment"
- Name it
pypi - Optionally add deployment protection rules (e.g., required reviewers)
- Save
No secrets need to be added to this environment — OIDC handles authentication.
How Releases Work
Day-to-Day Development
Use Conventional Commits for changes to the CLI:
Commits that don't match these patterns (or don't touch backend/cli/) are ignored by Release Please.
Release Flow
Where the changelog lives
- In the repo:
backend/cli/CHANGELOG.md— release-please writes to it on every Release PR. - On GitHub: the Releases page auto-mirrors each Release PR's CHANGELOG entry.
- On PyPI: PyPI does not natively render per-release changelogs. The
[project.urls]section inpyproject.tomlexposesChangelogandReleaseslinks in the project's PyPI sidebar — clicking them sends users to the locations above.
Manual Override
If you need to publish outside the Release Please flow:
Verifying a Release
After a publish completes:
Troubleshooting
"Trusted publisher not configured"
The OIDC publisher on pypi.org hasn't been set up, or the workflow name / environment name doesn't match. Double-check the values in the PyPI publisher config match exactly: workflow publish-pypi.yml, environment pypi.
Pre-publish validation fails
The built wheel includes dependencies it shouldn't (FastAPI, SQLModel, etc.). Check that the top-level pyproject.toml only lists CLI dependencies and that [tool.hatch.build.targets.wheel] only includes backend/cli.
Post-publish smoke test fails
PyPI propagation can take up to a minute. The workflow waits 30 seconds by default. If this is consistently failing, increase the sleep duration in the workflow.