Skip to content

A GPU task manager for Windows, Linux, and WSL: per-process VRAM, GPU activity, and LLM model/KV-cache insights (Windows AMD and NVIDIA).

Python

Publish Python releases to PyPI with Trusted Publishing

Scott Hanselman3b7d236af1fd
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5437cdf..659a016 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -111,6 +111,43 @@ jobs:
dist/*.tar.gz.sha256
if-no-files-found: error
+ build-python:
+ name: Python distributions
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: astral-sh/setup-uv@v6
+ with:
+ version: "0.13.6"
+ python-version: "3.13"
+ - run: uv lock --check
+ - run: uv build --out-dir python-dist
+ - uses: actions/upload-artifact@v4
+ with:
+ name: python-distributions
+ path: |
+ python-dist/*.whl
+ python-dist/*.tar.gz
+ if-no-files-found: error
+
+ publish-pypi:
+ name: Publish to PyPI
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
+ needs: [build, build-linux, build-python]
+ runs-on: ubuntu-latest
+ environment:
+ name: pypi
+ url: https://pypi.org/project/gputaskman/
+ permissions:
+ id-token: write
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ name: python-distributions
+ path: dist
+ - name: Publish wheel and source distribution
+ uses: pypa/gh-action-pypi-publish@release/v1
+
publish:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [build, build-linux]
diff --git a/AGENTS.md b/AGENTS.md
index f0b4121..3a9ad54 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -115,6 +115,12 @@ each extracted executable without Python, and publishes them together with check
notes. The build fails if the tag does not match `project.version`. A manual `workflow_dispatch`
run builds artifacts without publishing.
+The same workflow builds a wheel and source distribution, then publishes them to PyPI after all
+builds succeed on a tag. Trusted Publishing uses GitHub OIDC in the `pypi` environment; no API
+token is stored. The PyPI publisher must match owner `shanselman`, repository `gputaskman`,
+workflow `release.yml`, and environment `pypi`. Only the isolated publishing job has
+`id-token: write`; build jobs must not receive it.
+
## Contributor pull requests
- CI for fork PRs waits for approval:
diff --git a/README.md b/README.md
index 1328a8d..2b93467 100644
--- a/README.md
+++ b/README.md
@@ -719,7 +719,19 @@ The **Portable release** GitHub Actions workflow builds on `windows-2022` (x64),
oldest supported Ubuntu because the frozen binary needs the build machine's glibc or newer. A manual run produces downloadable workflow artifacts without publishing
a release. A pushed `vVERSION` tag must match `project.version` in `pyproject.toml`; once all builds
pass, the workflow publishes all four archives and checksums together with generated release notes.
-Build jobs have read-only permissions; only the tag-triggered publish job can write releases.
+The workflow also builds a Python wheel and source distribution. On tags, after all builds
+succeed, a separate job publishes them to PyPI using Trusted Publishing (GitHub OIDC), with no
+stored API token. Manual runs produce artifacts only and publish neither a GitHub release nor
+a PyPI package.
+
+Before the first PyPI publication, configure a pending publisher for project `gputaskman` on
+PyPI: owner `shanselman`, repository `gputaskman`, workflow `release.yml`, environment `pypi`.
+The workflow uses that exact GitHub environment; any environment approval rules must be satisfied
+before publishing. The first successful tagged publication creates the PyPI project. Once
+published, install with `uv tool install gputaskman` or `pipx install gputaskman` (Python 3.11+).
+
+Build jobs have read-only permissions; only the tag-triggered GitHub release job can write releases,
+and only the PyPI publishing job has `id-token: write`.
CI checks the extracted executable's `--help` outside the checkout with Python removed from `PATH`;
interactive rendering and real GPU snapshots require local hardware testing.