Skip to content

Commit 7ec6de0

Browse files
authored
ci(release): make the PyPI publisher dispatchable (#5222)
* ci(release): make the PyPI publisher dispatchable Move the PyPI upload into a reusable wheel-publish.yml with workflow_call and workflow_dispatch, called from release-publish.yml after the GitHub Release is created. PyPI Trusted Publishing matches job_workflow_ref, so calls and dispatches both authenticate as wheel-publish.yml. A failure in another publisher no longer skips PyPI, and a maintainer can publish a missing wheel for an existing release without rerunning Release. Write down that every release publisher keeps a manual trigger. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> * docs(agents): drop release publisher note from AGENTS.md The manual trigger rule lives in CI.md, which most changes do not need. Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> * docs(skills): point release workflow changes at the CI.md publisher rule Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com> --------- Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
1 parent 32dcc4a commit 7ec6de0

8 files changed

Lines changed: 130 additions & 64 deletions

File tree

‎.agents/skills/release-openshell/SKILL.md‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,15 @@ Watch the stable release run and report its result.
8686

8787
## PyPI publishing
8888

89-
Stable releases publish the built Python wheel directly to PyPI from the `publish-pypi` job in `release.yml`, after the other release publishers succeed. The job downloads the wheel from the stable GitHub Release, not the run's build artifact, and checks the stable tag's source commit and the wheel's release checksum. It uses Trusted Publishing with the `pypi` GitHub environment. Configure the `openshell` PyPI project's GitHub publisher with owner `NVIDIA`, repository `OpenShell`, workflow `release.yml`, and environment `pypi`. No PyPI API token or GitLab trigger credentials are required.
89+
Stable releases publish the Python wheel to PyPI from `wheel-publish.yml`, which the `publish-pypi` job in `release-publish.yml` calls after the GitHub Release is created. The workflow downloads the wheel from the stable GitHub Release, not a run's build artifact, and checks the stable tag's source commit and the wheel's release checksum. It uses Trusted Publishing with the `pypi` GitHub environment. PyPI matches the workflow file that contains the publishing job, so configure the `openshell` PyPI project's GitHub publisher with owner `NVIDIA`, repository `OpenShell`, workflow `wheel-publish.yml`, and environment `pypi`. No PyPI API token or GitLab trigger credentials are required.
9090

91-
The environment must allow the branch used to dispatch Release. For a support release, explicitly allow its support branch before dispatching. Required reviewers, if configured, must approve the PyPI job. Stable docs publish after PyPI succeeds. An existing wheel on PyPI is skipped when retrying Release; PyPI does not allow replacing a published wheel. Because the job publishes the release asset, a new Release run for the same tag can finish a failed PyPI upload.
91+
The environment must allow the branch used to dispatch Release or `wheel-publish.yml`. For a support release, explicitly allow its support branch before dispatching. Required reviewers, if configured, must approve the PyPI job. An existing wheel on PyPI is skipped; PyPI does not allow replacing a published wheel.
92+
93+
If a stable release did not reach PyPI, publish the wheel without rerunning Release:
94+
95+
```shell
96+
gh workflow run wheel-publish.yml -R NVIDIA/OpenShell --ref main \
97+
-f release-tag=vX.Y.Z -f source-sha=<tag commit> -f python-version=X.Y.Z
98+
```
9299

93100
Development and prerelease wheels remain GitHub Release assets and do not publish to PyPI.

‎.agents/skills/sync-agent-infra/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Run after adding, removing, or renaming a skill or crate; changing issue or PR c
2828
| TUI behavior | `tui-development` |
2929
| Release artifacts or smoke coverage | `test-release-canary` |
3030
| Release cadence, tagging, or qualification workflows | `release-captain` |
31+
| Release workflows or publishers | `release-openshell`, `release-captain`; keep the Release workflows table and the manual-trigger rule in `CI.md` current |
3132
| CI diagnostics | `watch-github-actions` |
3233
| Native Windows builds, runtime, or release branch guidance | `build-openshell-mxc-windows`; keep Windows implementation links on `windows` even in docs merged to `main` |
3334
| Gator supervision | `launch-openshell-gator` |

‎.github/workflows/release-prerelease.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ jobs:
124124
release-tag: ${{ needs.resolve.outputs.tag }}
125125
source-sha: ${{ needs.build.outputs.source_sha }}
126126
semver: ${{ needs.build.outputs.semver }}
127+
python-version: ${{ needs.build.outputs.python_version }}
127128
npm-version: ${{ needs.build.outputs.npm_version }}
128129
is-prerelease: true
129130
secrets:

‎.github/workflows/release-publish.yml‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
description: Release version without the v prefix
2828
required: true
2929
type: string
30+
python-version:
31+
description: Python package version
32+
required: true
33+
type: string
3034
npm-version:
3135
description: TypeScript package version
3236
required: true
@@ -518,6 +522,19 @@ jobs:
518522
buf push proto --label "${RELEASE_TAG}" \
519523
--source-control-url "${SOURCE_CONTROL_URL}"
520524
525+
publish-pypi:
526+
name: Publish Python Wheel
527+
needs: release
528+
if: ${{ !inputs.is-prerelease }}
529+
permissions:
530+
contents: read
531+
id-token: write
532+
uses: ./.github/workflows/wheel-publish.yml
533+
with:
534+
release-tag: ${{ inputs.release-tag }}
535+
source-sha: ${{ inputs.source-sha }}
536+
python-version: ${{ inputs.python-version }}
537+
521538
publish-snap:
522539
name: Publish Snap
523540
needs: release
@@ -583,6 +600,7 @@ jobs:
583600
- tag-ghcr-release
584601
- release-helm
585602
- release
603+
- publish-pypi
586604
- publish-snap
587605
- publish-prerelease-snap
588606
- publish-sdk-typescript
@@ -602,7 +620,7 @@ jobs:
602620
if [[ "${IS_PRERELEASE}" == "true" ]]; then
603621
expected+=(publish-prerelease-snap)
604622
else
605-
expected+=(publish-sdk-typescript tag-sdk-go)
623+
expected+=(publish-pypi publish-sdk-typescript tag-sdk-go)
606624
if [[ "${MAKE_LATEST}" == "true" ]]; then
607625
expected+=(publish-snap)
608626
fi

‎.github/workflows/release.yml‎

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -153,71 +153,17 @@ jobs:
153153
release-tag: ${{ needs.promote.outputs.tag }}
154154
source-sha: ${{ needs.build.outputs.source_sha }}
155155
semver: ${{ needs.build.outputs.semver }}
156+
python-version: ${{ needs.build.outputs.python_version }}
156157
npm-version: ${{ needs.build.outputs.npm_version }}
157158
is-prerelease: false
158159
make-latest: ${{ needs.promote.outputs.make-latest == 'true' }}
159160
secrets:
160161
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
161162
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
162163

163-
publish-pypi:
164-
name: Publish Python Wheel to PyPI
165-
needs: [promote, build, publish]
166-
runs-on: ubuntu-latest
167-
timeout-minutes: 10
168-
environment:
169-
name: pypi
170-
url: https://pypi.org/project/openshell/
171-
permissions:
172-
contents: read
173-
id-token: write
174-
steps:
175-
# Publish the wheel attached to the GitHub Release rather than this run's
176-
# build artifact, so a later run can finish publishing the same bytes.
177-
- name: Download and verify the released wheel
178-
shell: bash
179-
env:
180-
GH_TOKEN: ${{ github.token }}
181-
RELEASE_TAG: ${{ needs.promote.outputs.tag }}
182-
SOURCE_SHA: ${{ needs.build.outputs.source_sha }}
183-
PYTHON_VERSION: ${{ needs.build.outputs.python_version }}
184-
run: |
185-
set -euo pipefail
186-
tag_sha=$(gh api "repos/${GITHUB_REPOSITORY}/commits/${RELEASE_TAG}" --jq .sha)
187-
if [[ "${tag_sha}" != "${SOURCE_SHA}" ]]; then
188-
echo "${RELEASE_TAG} points to ${tag_sha}, not ${SOURCE_SHA}" >&2
189-
exit 1
190-
fi
191-
gh release download "${RELEASE_TAG}" -R "${GITHUB_REPOSITORY}" \
192-
--pattern '*.whl' --pattern openshell-checksums-sha256.txt --dir release
193-
shopt -s nullglob
194-
wheels=(release/*.whl)
195-
if [[ "${#wheels[@]}" -ne 1 ]]; then
196-
echo "Expected exactly one Python wheel on ${RELEASE_TAG}, found ${#wheels[@]}" >&2
197-
exit 1
198-
fi
199-
wheel=$(basename "${wheels[0]}")
200-
if [[ "${wheel}" != openshell-"${PYTHON_VERSION}"-*.whl ]]; then
201-
echo "${wheel} is not an openshell ${PYTHON_VERSION} wheel" >&2
202-
exit 1
203-
fi
204-
checksum=$(awk -v wheel="${wheel}" '$2 == wheel { print $1 " " $2 }' release/openshell-checksums-sha256.txt)
205-
if [[ -z "${checksum}" ]]; then
206-
echo "${wheel} is missing from the release checksums" >&2
207-
exit 1
208-
fi
209-
(cd release && sha256sum -c - <<<"${checksum}")
210-
mkdir dist
211-
mv "release/${wheel}" dist/
212-
213-
- name: Publish wheel to PyPI
214-
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
215-
with:
216-
skip-existing: true
217-
218164
publish-fern-docs:
219165
name: Sync and Publish Fern Docs
220-
needs: [build, publish, publish-pypi]
166+
needs: [build, publish]
221167
permissions:
222168
contents: write
223169
uses: ./.github/workflows/sync-docs.yml
@@ -234,7 +180,7 @@ jobs:
234180

235181
check-publication:
236182
name: Check Stable Publication
237-
needs: [promote, build, release-notes, publish, publish-pypi, publish-fern-docs]
183+
needs: [promote, build, release-notes, publish, publish-fern-docs]
238184
if: ${{ always() && !inputs.notes-only }}
239185
runs-on: ubuntu-latest
240186
timeout-minutes: 2
@@ -250,7 +196,7 @@ jobs:
250196
251197
notify-release-failure:
252198
name: Notify Release Failure
253-
needs: [promote, build, release-notes, publish, publish-pypi, publish-fern-docs, check-publication]
199+
needs: [promote, build, release-notes, publish, publish-fern-docs, check-publication]
254200
if: failure()
255201
runs-on: ubuntu-latest
256202
timeout-minutes: 2
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Publish Wheel
5+
6+
# PyPI Trusted Publishing matches the `job_workflow_ref` claim, which names this
7+
# file for both calls and dispatches. The `openshell` PyPI project trusts
8+
# workflow `wheel-publish.yml` with environment `pypi`.
9+
on:
10+
workflow_call:
11+
inputs:
12+
release-tag:
13+
required: true
14+
type: string
15+
source-sha:
16+
required: true
17+
type: string
18+
python-version:
19+
required: true
20+
type: string
21+
workflow_dispatch:
22+
inputs:
23+
release-tag:
24+
description: Stable tag whose GitHub Release holds the wheel, e.g. v0.1.7
25+
required: true
26+
type: string
27+
source-sha:
28+
description: Commit the tag points to
29+
required: true
30+
type: string
31+
python-version:
32+
description: Python package version, e.g. 0.1.7
33+
required: true
34+
type: string
35+
36+
permissions:
37+
contents: read
38+
39+
jobs:
40+
publish:
41+
name: Publish Python Wheel to PyPI
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 10
44+
environment:
45+
name: pypi
46+
url: https://pypi.org/project/openshell/
47+
permissions:
48+
contents: read
49+
id-token: write
50+
steps:
51+
# Publish the wheel attached to the GitHub Release rather than a run's
52+
# build artifact, so a retry or dispatch publishes the same bytes.
53+
- name: Download and verify the released wheel
54+
shell: bash
55+
env:
56+
GH_TOKEN: ${{ github.token }}
57+
RELEASE_TAG: ${{ inputs.release-tag }}
58+
SOURCE_SHA: ${{ inputs.source-sha }}
59+
PYTHON_VERSION: ${{ inputs.python-version }}
60+
run: |
61+
set -euo pipefail
62+
tag_sha=$(gh api "repos/${GITHUB_REPOSITORY}/commits/${RELEASE_TAG}" --jq .sha)
63+
if [[ "${tag_sha}" != "${SOURCE_SHA}" ]]; then
64+
echo "${RELEASE_TAG} points to ${tag_sha}, not ${SOURCE_SHA}" >&2
65+
exit 1
66+
fi
67+
gh release download "${RELEASE_TAG}" -R "${GITHUB_REPOSITORY}" \
68+
--pattern '*.whl' --pattern openshell-checksums-sha256.txt --dir release
69+
shopt -s nullglob
70+
wheels=(release/*.whl)
71+
if [[ "${#wheels[@]}" -ne 1 ]]; then
72+
echo "Expected exactly one Python wheel on ${RELEASE_TAG}, found ${#wheels[@]}" >&2
73+
exit 1
74+
fi
75+
wheel=$(basename "${wheels[0]}")
76+
if [[ "${wheel}" != openshell-"${PYTHON_VERSION}"-*.whl ]]; then
77+
echo "${wheel} is not an openshell ${PYTHON_VERSION} wheel" >&2
78+
exit 1
79+
fi
80+
checksum=$(awk -v wheel="${wheel}" '$2 == wheel { print $1 " " $2 }' release/openshell-checksums-sha256.txt)
81+
if [[ -z "${checksum}" ]]; then
82+
echo "${wheel} is missing from the release checksums" >&2
83+
exit 1
84+
fi
85+
(cd release && sha256sum -c - <<<"${checksum}")
86+
mkdir dist
87+
mv "release/${wheel}" dist/
88+
89+
- name: Publish wheel to PyPI
90+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
91+
with:
92+
skip-existing: true

‎CI.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,21 +694,23 @@ The bot's full administrator documentation is internal to NVIDIA. The only comma
694694

695695
These workflows run after merge to publish dev/tagged artifacts and verify them. They are not PR-gated.
696696

697+
Each step that publishes to an external registry, store, or site lives in its own workflow with both `workflow_call` and `workflow_dispatch`. Release calls it, and a maintainer can dispatch it to finish one missing publication for an existing release without rerunning Release. Dispatch inputs identify an already-published release, such as its tag and source commit; the workflow verifies them before publishing and should skip what is already published. Keep the manual trigger when changing or moving a publisher.
698+
697699
| File | Role |
698700
|---|---|
699701
| `.github/workflows/release-dev.yml` | Publishes the rolling `dev` build on every push to `main`. Builds gateway, sandbox, and supervisor images and binaries, packages, wheels, and pushes the Helm chart as `oci://ghcr.io/nvidia/openshell/helm-chart:0.0.0-dev` (plus an immutable `0.0.0-dev.<sha>` pin). Also dispatchable manually. |
700702
| `.github/workflows/release.yml` | Manually promote the latest qualified prerelease for a version and branch, create its stable tag, then rebuild and publish. Support releases preserve shared latest channels. Publishes the prerelease's notes preview, retagged, or generates notes when it is unavailable. The notes-only mode generates a release notes preview artifact. Published artifacts are never overwritten: a rerun fills in what is missing, and a bad published artifact is fixed by releasing a new patch version. |
701703
| `.github/workflows/release-auto-tag.yml` | Weekdays at 14:00 Europe/Zurich, tags the next `-pre.N` on `main` when commits landed since the latest one, then dispatches Pre-release. It skips when the train has no `-pre.1` or its version is already stable, so push each train's `-pre.1` tag by hand. |
702704
| `.github/workflows/release-prerelease.yml` | Pre-release orchestrator, triggered by prerelease tag pushes or dispatched by Release Auto-Tag or manually. A tagless dispatch creates the next candidate on its branch; explicit tags select existing candidates. Builds, then publishes and qualifies in parallel. Qualification failure fails the run and sends the failure notification; published artifacts remain available. |
703705
| `.github/workflows/release-build.yml` | Shared version computation, binary and image builds, and package builds. Validates that the tag matches the caller's release kind. |
704-
| `.github/workflows/release-publish.yml` | Shared artifact assembly, OCI image tags and Helm chart publication, and package publication. Stable releases also publish release-labeled public schemas to Buf (`BUF_TOKEN` required), GitHub Releases, snap, npm, PyPI, and Fern. |
706+
| `.github/workflows/release-publish.yml` | Shared artifact assembly, OCI image tags and Helm chart publication, and package publication. Stable releases also publish release-labeled public schemas to Buf (`BUF_TOKEN` required) and GitHub Releases, and call the PyPI, snap, npm, and Go SDK publishers. |
705707
| `.github/workflows/release-notes.yml` | Shared prompt-driven release notes generation through Inference Hub, used by prerelease previews, notes-only previews, and stable releases. Stable releases reuse the promoted prerelease's preview when available. |
706708
| `.github/workflows/release-qualification.yml` | Reusable qualification suites and result aggregation. Runs security scans, conformance and feature integration, Docker and VM E2E, protobuf compatibility, and advisory compatibility review. |
707709
| `.github/workflows/snap-package.yml` | Builds snap and component artifacts for Release Dev, Release, and Pre-release without Store credentials or publication. |
708710
| `.github/workflows/snap-publish.yml` | Uploads existing snap and component artifacts directly to a Store channel without rebuilding. Release Dev uses `latest/edge`, Pre-release uses `latest/beta`, and Release uses `latest/stable` for the stable rebuild. Uploads queue per channel and architecture, so tagged beta and stable jobs recheck repository tags after earlier publication finishes and before updating their floating channels. Manual dispatch uploads the `snap-linux-*` artifacts from `artifact-run-id`. |
709711
| `.github/workflows/sdk-typescript-publish.yml` | Publishes the TypeScript SDK to GitHub Packages. Called by stable Release; manual dispatch publishes a given tag and npm version. |
710712
| `.github/workflows/sdk-go-tag.yml` | Creates the `sdk/go/vX.Y.Z` tag and asks the Go module proxy to fetch it. Called by stable Release; manual dispatch tags a given version and commit. |
711-
| `.github/workflows/wheel-publish.yml` | Triggers the GitLab pipeline that publishes wheels from a GitHub Release to PyPI. Called by stable Release; manual dispatch republishes a given tag. |
713+
| `.github/workflows/wheel-publish.yml` | Publishes the wheel attached to a stable GitHub Release to PyPI with Trusted Publishing in the `pypi` environment. Called by stable Release; manual dispatch publishes a given tag. |
712714
| `.github/workflows/release-canary.yml` | Smoke-tests published dev artifacts in the `macos`, `ubuntu-deb`, `ubuntu-snap-system-docker`, `fedora`, and `kubernetes` (kind + Helm) jobs. Each job reaches its gateway and creates, exercises, and deletes a sandbox. The `ubuntu-snap-system-docker` job verifies a compatible system Docker lifecycle, while `ubuntu-snap-docker-preflight` tests fail-fast behavior when Docker is absent or supplied by the Docker snap. The positive snap lane also runs a local policy containment check with the packaged prover. It runs automatically after `Release Dev` succeeds and supports manual dispatch (`gh workflow run release-canary.yml --ref <branch>`). See the `test-release-canary` skill for the playbook and local kind reproduction. |
713715

714716
## Required status contexts

‎tasks/scripts/sync_docs_website_test.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def test_release_workflows_sync_and_publish_docs_once() -> None:
5252
assert tag_job["needs"] == [
5353
"build",
5454
"publish",
55-
"publish-pypi",
5655
]
5756
assert tag_job["uses"] == "./.github/workflows/sync-docs.yml"
5857
assert tag_job["with"]["channel"] == "stable"

0 commit comments

Comments
 (0)