Skip to content

Publish miles-rl wheel to PyPI via Trusted Publishing (Phase 7) - #1231

Closed
Shi-Dong wants to merge 1 commit into
shi/phase6-bundle-third-party-into-milesfrom
shi/phase7-publish-pypi
Closed

Publish miles-rl wheel to PyPI via Trusted Publishing (Phase 7)#1231
Shi-Dong wants to merge 1 commit into
shi/phase6-bundle-third-party-into-milesfrom
shi/phase7-publish-pypi

Conversation

@Shi-Dong

Copy link
Copy Markdown
Contributor

Summary

  • Adds .github/workflows/publish-pypi.yml: publishes the bundled miles-rl wheel to https://pypi.org/ via PyPI Trusted Publishing (OIDC). No long-lived API token in the repo's secrets.
  • Bumps setup.py version from 0.2.1 to 0.0.1 — the first public miles-rl release.

Why

Phase 7 of the pip install miles-rl roadmap, completing the journey:

Why OIDC / Trusted Publishing

  • No PYPI_API_TOKEN secret in the repo. Tokens stored in CI are a known leak surface.
  • PyPI verifies, per upload, that the GitHub OIDC token's claims match the pre-registered publisher: owner=radixark, repo=miles, workflow=publish-pypi.yml. An attacker who somehow got code into a different workflow couldn't upload as miles-rl.
  • The publisher has already been pre-registered on PyPI (miles-rl, publish-pypi.yml, no environment) — confirmed by the project owner.

Safety nets in the workflow

  • dry_run defaults to true on workflow_dispatch. Accidentally firing the workflow just builds the wheel; uploading requires explicit dry_run=false.
  • Pre-upload version check. Before invoking pypa/gh-action-pypi-publish, the workflow curls https://pypi.org/pypi/miles-rl/<version>/json. If PyPI already has that version (PyPI versions are immutable), the workflow hard-fails with a clear error instead of letting twine return a confusing 400.
  • Post-upload smoke install. A fresh python:3.11 venv runs pip install miles-rl==<version> from real PyPI and verifies (via importlib.util.find_spec, no init execution) that the bundled miles, miles_plugins, miles_megatron_plugins, sglang, megatron, megatron.core, megatron.training all land at the expected site-packages paths.

Test plan

  • Auto-fired dry-run on push (run 26523348212): wheel built (8.2 MB), no PyPI contact, all upload steps cleanly skipped.
  • Manual confirmation gate: before triggering the real upload, project owner explicitly approves. Then gh workflow run publish-pypi.yml --ref shi/phase7-publish-pypi -f dry_run=false. This is the first upload that claims miles-rl on PyPI permanently.
  • After upload: pip install miles-rl==0.0.1 on a fresh production-equivalent devbox (image: radixark/miles:dev), then python -c "import miles; import sglang; import megatron.core; import megatron.training; import miles_megatron_plugins.true_on_policy.contracts" with PYTHONPATH unset (this is the real end-to-end test, matching the one we ran on TestPyPI for Phase 6).

Stacked on

radixark/miles PR #1226 (Phase 6 bundling).

Pre-merge cleanup

  • Remove the bootstrap push: trigger from publish-pypi.yml once it has landed on the default branch (only workflow_dispatch should remain for subsequent releases).

After this PR merges

For each subsequent miles-rl release:

  1. Bump version= in setup.py to a new PEP 440-compliant string.
  2. Open a PR with that bump (plus whatever other changes the release contains).
  3. After merge, trigger gh workflow run publish-pypi.yml --ref main -f dry_run=false. The wheel is built from main and uploaded.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the version of the miles-rl package in setup.py from '0.2.1' to '0.0.1' for its first public PyPI release, adding a comment explaining the versioning strategy. There are no review comments, and I have no feedback to provide.

@Shi-Dong
Shi-Dong marked this pull request as ready for review May 28, 2026 06:50
@Shi-Dong
Shi-Dong requested a review from yushengsu-thu as a code owner May 28, 2026 06:50
@Shi-Dong
Shi-Dong force-pushed the shi/phase6-bundle-third-party-into-miles branch from 45f2041 to 5d64d45 Compare May 30, 2026 08:17
@Shi-Dong
Shi-Dong force-pushed the shi/phase7-publish-pypi branch 2 times, most recently from 9a66871 to 9ef42e9 Compare June 1, 2026 16:12
@Shi-Dong
Shi-Dong force-pushed the shi/phase6-bundle-third-party-into-miles branch 2 times, most recently from 484d7cd to 60ff36a Compare June 2, 2026 04:40
@Shi-Dong
Shi-Dong force-pushed the shi/phase7-publish-pypi branch from 9ef42e9 to 1e4511e Compare June 2, 2026 04:40
@Shi-Dong
Shi-Dong force-pushed the shi/phase6-bundle-third-party-into-miles branch from 60ff36a to c08360a Compare June 2, 2026 09:07
@Shi-Dong
Shi-Dong force-pushed the shi/phase7-publish-pypi branch from 1e4511e to 335b60f Compare June 2, 2026 09:07
@Shi-Dong
Shi-Dong force-pushed the shi/phase6-bundle-third-party-into-miles branch from c08360a to ccdd862 Compare June 3, 2026 15:02
@Shi-Dong
Shi-Dong force-pushed the shi/phase7-publish-pypi branch from 335b60f to a0afd1f Compare June 3, 2026 15:02
Adds .github/workflows/publish-pypi.yml that uses pypa/gh-action-pypi-publish with OIDC. PyPI has been pre-registered to trust this exact workflow + repo, so no PYPI_API_TOKEN secret is needed.

Bumps setup.py version from 0.2.1 to 0.0.1: the first public miles-rl release. This is what the workflow will upload on the first non-dry-run invocation; PyPI version-immutability means this number will claim the public miles-rl namespace forever.

Safety nets in the workflow: (1) dry_run defaults to true on workflow_dispatch so an accidental fire just builds the wheel; (2) pre-upload check curls PyPI for the version to fail fast if its already published; (3) post-upload smoke install validates pip install miles-rl from real PyPI works and the bundled sglang/megatron/miles packages all land at the expected site-packages paths.
@Shi-Dong
Shi-Dong force-pushed the shi/phase6-bundle-third-party-into-miles branch from ccdd862 to 9f5cdd3 Compare June 4, 2026 13:10
@Shi-Dong
Shi-Dong force-pushed the shi/phase7-publish-pypi branch from a0afd1f to 371783b Compare June 4, 2026 13:10
@Shi-Dong

Copy link
Copy Markdown
Contributor Author

Superseded. Replaced by a thin packaging slice cut fresh off current `main`:

This branch was 457 commits behind `main` and its submodule pin for sglang was 2831 commits stale and no longer an ancestor of `sglang-miles`. Rebasing it would also have resurrected the `examples/experimental/swe-agent` submodules that #1918 deliberately deleted. The branch is left in place; nothing is lost.

@Shi-Dong Shi-Dong closed this Aug 13, 2026
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.

1 participant