Skip to content

ci: add PyPI publish workflow with Trusted Publisher OIDC#148

Draft
abubnalitic-nbl wants to merge 1 commit into
mainfrom
feat/pypi-publish-workflow
Draft

ci: add PyPI publish workflow with Trusted Publisher OIDC#148
abubnalitic-nbl wants to merge 1 commit into
mainfrom
feat/pypi-publish-workflow

Conversation

@abubnalitic-nbl

Copy link
Copy Markdown
Contributor

Adds a PyPI publish workflow so a v*.*.* tag — already produced by release-finalize.yml — also pushes the sdist and wheel to PyPI. Uses PyPI Trusted Publishers (OIDC), so no API token is stored in the repo.

The build and publish steps are split across two jobs so the OIDC token (id-token: write) is only present in the publish job, not while uv build is running — same pattern the existing docker-publish.yml uses for its build/merge split. SLSA build provenance is attested for the uploaded artifacts, matching the docker workflow.

Draft — do not merge yet

Merging this workflow alone publishes nothing; the OIDC exchange fails closed without the matching PyPI-side registration. Before this can land, the holder of the netboxlabs-publisher PyPI account needs to:

  • Configure a trusted publisher (or pending publisher, since the project doesn't exist yet) on PyPI for netbox-mcp-server, pointing at:
    • owner: netboxlabs
    • repo: netbox-mcp-server
    • workflow: pypi-publish.yml
    • environment: pypi
  • Create the pypi GitHub Environment in repo Settings → Environments, with a deployment branch/tag rule restricting it to v* tags
  • Optionally require a reviewer on the pypi environment for the first run

The workflow header in pypi-publish.yml documents these steps inline so the access holder can configure straight from the file.

Verification done locally

  • uv build produces netbox_mcp_server-1.2.0.tar.gz (188K) and netbox_mcp_server-1.2.0-py3-none-any.whl (25K)
  • [project.scripts] already wires netbox-mcp-servernetbox_mcp_server.server:main, so uvx netbox-mcp-server will work once published

Relates to #130.

Triggers on `v*.*.*` tags created by `release-finalize.yml`, building
the sdist and wheel with `uv build` and uploading via PyPI Trusted
Publishers (no API token in the repo).

Build and publish are split across jobs so the OIDC token is only
available to the publish step, mirroring the docker-publish.yml
build/merge split. SLSA build provenance attestation matches the
existing docker-publish workflow.

Setup prerequisites (one-time, owned by the `netboxlabs-publisher`
PyPI account) are documented in the workflow header. Do not merge
until those are configured — see #130.

Relates to #130
subject-path: "dist/*"

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
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