Skip to content

ci: publish to PyPI and TestPyPI via trusted publishing - #92

Merged
kannandreams merged 2 commits into
mainfrom
ci/pypi-trusted-publishing
Aug 26, 2026
Merged

ci: publish to PyPI and TestPyPI via trusted publishing#92
kannandreams merged 2 commits into
mainfrom
ci/pypi-trusted-publishing

Conversation

@kannandreams

Copy link
Copy Markdown
Collaborator

Summary

Adds PyPI publishing to the release workflow so GitHub Releases and PyPI ship the same bytes from one build.

  • publish-pypi — runs on v* tags, after publish-release, uploads the downloaded wheels + sdist to https://pypi.org/p/glyf-core with pypa/gh-action-pypi-publish via OIDC trusted publishing (environment: pypi, id-token: write). No PyPI tokens in secrets.
  • publish-testpypiworkflow_dispatch with the new publish_to_testpypi input: full build, then upload to TestPyPI (environment: testpypi, skip-existing). Dispatching without the input just exercises the build matrix.
  • check-version — first job; fails if pyproject.toml, Cargo.toml, and src/glyf/__init__.py disagree, or if a tag vX.Y.Z doesn't match the package version.
  • twine check --strict before every upload.
  • docs/release.md documents the dry run and the one-time trusted-publisher setup.

Design note: PyPI's docs state reusable workflows can't be used as a trusted publisher, so the publish jobs live in release.yml rather than a separate pypi.yml; the trusted publisher on PyPI/TestPyPI must be registered with workflow name release.yml.

One-time setup still needed (outside this PR)

  • GitHub environments pypi and testpypi are created on the repo already.
  • On pypi.org and test.pypi.org: add a pending trusted publisher for project glyf-core — owner glyf-data, repo glyf, workflow release.yml, environment pypi / testpypi.

Verification

  • YAML parses; job graph: check-version → build-wheels/build-sdist → publish-release → publish-pypi, publish-testpypi off build-* on dispatch only.
  • Version-check script run locally: pyproject=0.3.0 cargo=0.3.0 init=0.3.0.
  • End-to-end is verified by the TestPyPI dry run after merge.

Add publish-pypi (on v* tags, after the GitHub Release) and
publish-testpypi (workflow_dispatch dry run) jobs that upload the same
built artifacts using OIDC trusted publishing and GitHub environments; no
API tokens in secrets. Add a check-version job that refuses a tag whose
name does not match the package version or when pyproject.toml,
Cargo.toml and __init__.py disagree.
@kannandreams
kannandreams merged commit f442fd6 into main Aug 26, 2026
4 checks passed
@kannandreams
kannandreams deleted the ci/pypi-trusted-publishing branch August 26, 2026 22:50
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