Skip to content

CI: publish to PyPI with trusted publishing instead of pinned flit and a long-lived token #975

Open

Description

@mmcky

The v0.12.0 publish failed on its first attempt (run 35960284940): the job installs flit~=3.6, which resolves to flit 3.12.0, and that release only requires flit_core>=3.12.0 with no upper bound, so pip paired it with flit_core 4.1.0 (the 4.x series started in August 2026), which dropped the gen_setup_py argument flit 3.x still passes. #974 pinned both to the 3.12 series and added a workflow_dispatch path that publishes an existing tag, and a manual dispatch (run 35970324623) got 0.12.0 out. The job still depends on version pins that will need attention again, and on the long-lived PYPI_TOKEN repository secret.

Proposal. Build with python -m build and upload with pypa/gh-action-pypi-publish using PyPI trusted publishing (OIDC). That removes the flit pins, retires the token, and the id-token: write permission makes it explicit which job may publish. The manual dispatch path from #974 should be kept: it checks out refs/tags/<input>, so only an existing tag can be published.

Steps.

  1. On the PyPI project, register a GitHub publisher: owner QuantEcon, repository QuantEcon.py, workflow ci.yml, optionally a pypi environment if we want an approval gate before upload. This needs a PyPI project owner.
  2. In .github/workflows/ci.yml, give the publish job permissions: id-token: write (and contents: read), replace the "Install flit" and "Build and publish" steps with pip install build, python -m build, and the pypa/gh-action-pypi-publish action.
  3. After the next release has gone through the new path, delete PYPI_TOKEN from the repository secrets.

The publish job is gated on the test matrix (needs: [tests]) and that should stay as it is.

Activity

  1. added
    infrastructure
    on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CIinfrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions