Skip to content

ci: add PyPI publishing on tag push#71

Merged
ericchansen merged 3 commits intomasterfrom
ci/pypi-publish
Mar 19, 2026
Merged

ci: add PyPI publishing on tag push#71
ericchansen merged 3 commits intomasterfrom
ci/pypi-publish

Conversation

@ericchansen
Copy link
Copy Markdown
Owner

Summary

Set up automated PyPI publishing so that pushing a git tag (v5.0.0) automatically builds and publishes the package to PyPI.

Changes

New: .github/workflows/publish.yml

  • Triggers on v* tag pushes
  • Builds sdist + wheel using python -m build
  • Verifies the package version matches the git tag
  • Publishes via PyPI trusted publishing (OIDC -- no API tokens stored)
  • Uses a pypi environment for deployment protection

Updated: pyproject.toml

  • Dynamic versioning: Switched from static version = "5.0.0" to setuptools-scm which derives the version from git tags automatically
  • PyPI metadata: Added readme, keywords, classifiers for a proper PyPI listing
  • Dev deps: Added build to dev extras

How it works

# Tag a release
git tag v5.0.0
git push --tags

# GitHub Actions automatically:
# 1. Builds sdist + wheel (version = 5.0.0 from tag)
# 2. Verifies version matches tag
# 3. Publishes to PyPI via OIDC trusted publisher

Users can then install with:

pip install q2mm
pip install q2mm[openmm]    # with OpenMM backend
pip install q2mm[all]       # everything

One-time setup required

Before the first publish, register a pending publisher on PyPI:

  1. Go to https://pypi.org/manage/account/publishing/
  2. Add a pending publisher:
    • PyPI project name: q2mm
    • Owner: ericchansen
    • Repository: q2mm
    • Workflow name: publish.yml
    • Environment name: pypi
  3. Create a pypi environment in GitHub repo settings (Settings > Environments > New)

Verified locally

  • python -m build produces q2mm-4.1.dev55.tar.gz and .whl successfully
  • setuptools-scm correctly derives version from git tags
  • Ruff lint clean

- Add .github/workflows/publish.yml triggered on v* tags
- Switch to setuptools-scm for dynamic version from git tags
- Enrich pyproject.toml with classifiers, keywords, readme for PyPI
- Add build to dev dependencies
- Uses OIDC trusted publishing (no API tokens needed)

Workflow: git tag v5.0.0 && git push --tags → builds → publishes to PyPI.

Requires one-time setup: add pending publisher at
https://pypi.org/manage/account/publishing/ with:
  - Owner: ericchansen
  - Repository: q2mm
  - Workflow: publish.yml
  - Environment: pypi

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Auto-create GitHub Release on tag push with generated notes
- Pre-release tags (a, b, rc, dev) marked as pre-release on GitHub
- Stable tags create full releases with attached dist artifacts
- Bumped permissions to contents: write for release creation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions release pipeline to publish q2mm to PyPI on v* tag pushes, and updates packaging metadata to support tag-derived versions.

Changes:

  • Introduces .github/workflows/publish.yml to build sdist/wheel on tag push and publish to PyPI via OIDC trusted publishing.
  • Switches pyproject.toml to dynamic versioning using setuptools-scm and expands PyPI metadata (readme/keywords/classifiers).
  • Adds build to the dev optional dependency group.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pyproject.toml Enables setuptools-scm dynamic versioning and improves PyPI metadata/extras.
.github/workflows/publish.yml Adds tag-triggered build + version check + PyPI publish workflow using OIDC.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment thread .github/workflows/publish.yml
Use importlib.metadata.version() so __version__ stays in sync with
setuptools-scm derived version from git tags. Fallback to dev sentinel
for editable installs or uninstalled imports.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ericchansen ericchansen merged commit 4d0b5bf into master Mar 19, 2026
5 checks passed
@ericchansen ericchansen deleted the ci/pypi-publish branch March 19, 2026 20:17
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.

2 participants