diff --git a/.github/workflows/release-pypi-pr.yml b/.github/workflows/release-pypi-pr.yml
new file mode 100644
index 000000000..efcc1bcbb
--- /dev/null
+++ b/.github/workflows/release-pypi-pr.yml
@@ -0,0 +1,174 @@
+name: Release PyPI PR Wheels
+
+on:
+ workflow_dispatch:
+ inputs:
+ pr_number:
+ description: 'PR number to build wheel for'
+ required: true
+ type: string
+ pr_branch:
+ description: 'PR branch name to build from (e.g., my-feature-branch or refs/pull/123/head)'
+ required: true
+ type: string
+
+concurrency:
+ group: build-pr-wheel-${{ github.event.inputs.pr_number }}
+ cancel-in-progress: true
+
+jobs:
+ build-pr-wheel:
+ if: github.repository == 'sgl-project/sglang'
+ runs-on: ubuntu-latest
+ outputs:
+ wheel_version: ${{ steps.gen_version.outputs.wheel_version }}
+ commit_hash: ${{ steps.gen_version.outputs.commit_hash }}
+ build_date: ${{ steps.gen_version.outputs.build_date }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ inputs.pr_branch }}
+ fetch-depth: 0 # Need full history for version generation
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.10"
+
+ - name: Generate PR wheel version
+ id: gen_version
+ run: |
+ # Get base version from version.py
+ BASE_VERSION=$(cat python/sglang/version.py | cut -d'"' -f2)
+
+ # Get commit info
+ COMMIT_HASH=$(git rev-parse --short HEAD)
+ COMMIT_COUNT=$(git rev-list --count HEAD)
+
+ # Get current date in YYYY-MM-DD format
+ BUILD_DATE=$(date -u +%Y-%m-%d)
+
+ # Always use pr-{number} format for suffix
+ SUFFIX="pr-${{ inputs.pr_number }}"
+
+ # Generate PR wheel version following PEP 440
+ # Format: {base_version}.dev{commit_count}+pr-{number}.g{commit_hash}
+ WHEEL_VERSION="${BASE_VERSION}.dev${COMMIT_COUNT}+${SUFFIX}.g${COMMIT_HASH}"
+
+ echo "Base version: ${BASE_VERSION}"
+ echo "PR wheel version: ${WHEEL_VERSION}"
+ echo "Commit: ${COMMIT_HASH}"
+ echo "Build date: ${BUILD_DATE}"
+
+ echo "wheel_version=${WHEEL_VERSION}" >> $GITHUB_OUTPUT
+ echo "commit_hash=${COMMIT_HASH}" >> $GITHUB_OUTPUT
+ echo "base_version=${BASE_VERSION}" >> $GITHUB_OUTPUT
+ echo "build_date=${BUILD_DATE}" >> $GITHUB_OUTPUT
+
+ - name: Update pyproject.toml with PR wheel version
+ run: |
+ cd python
+ BASE_VERSION=$(cat sglang/version.py | cut -d'"' -f2)
+ WHEEL_VERSION="${{ steps.gen_version.outputs.wheel_version }}"
+
+ # Update version (temporary, not committed)
+ sed -i "s/version = \"${BASE_VERSION}\"/version = \"${WHEEL_VERSION}\"/" pyproject.toml
+
+ # Verify update
+ echo "Updated version in pyproject.toml:"
+ grep "^version" pyproject.toml
+
+ - name: Install build dependencies
+ run: |
+ cd python
+ pip install build wheel setuptools
+
+ - name: Build wheel
+ run: |
+ cd python
+ cp ../README.md ../LICENSE .
+ python3 -m build --wheel
+
+ # List built wheels
+ echo "Built wheel:"
+ ls -lh dist/
+
+ - name: Upload wheel artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: pr-wheel-${{ inputs.pr_number }}
+ path: python/dist/*.whl
+ retention-days: 30
+
+ release-pr-wheel:
+ needs: build-pr-wheel
+ runs-on: ubuntu-latest
+ environment: 'prod'
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Download wheel artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: pr-wheel-${{ inputs.pr_number }}
+ path: dist/
+
+ - name: List downloaded wheels
+ run: |
+ echo "Downloaded wheel:"
+ ls -lh dist/
+
+ - name: Create GitHub Release for PR wheel
+ uses: softprops/action-gh-release@v2
+ with:
+ tag_name: pr-${{ inputs.pr_number }}-${{ needs.build-pr-wheel.outputs.build_date }}-${{ needs.build-pr-wheel.outputs.commit_hash }}
+ name: PR #${{ inputs.pr_number }} Build (${{ needs.build-pr-wheel.outputs.commit_hash }})
+ repository: sgl-project/whl
+ token: ${{ secrets.GH_PAT_FOR_WHL_RELEASE }}
+ prerelease: true
+ body: |
+ PR wheel build from PR #${{ inputs.pr_number }}
+ Commit: ${{ github.sha }}
+ Build date: ${{ needs.build-pr-wheel.outputs.build_date }}
+ Version: ${{ needs.build-pr-wheel.outputs.wheel_version }}
+
+ **Installation via index:**
+ ```bash
+ pip install sglang=={version} --index-url https://sgl-project.github.io/whl/pr/
+ ```
+
+ **Direct installation:**
+ ```bash
+ pip install https://github.com/sgl-project/whl/releases/download/pr-${{ inputs.pr_number }}-${{ needs.build-pr-wheel.outputs.build_date }}-${{ needs.build-pr-wheel.outputs.commit_hash }}/sglang-${{ needs.build-pr-wheel.outputs.wheel_version }}-py3-none-any.whl
+ ```
+ files: |
+ dist/*.whl
+
+ - name: Clone wheel index repository
+ run: |
+ git clone https://oauth2:${WHL_TOKEN}@github.com/sgl-project/whl.git sgl-whl
+ cd sgl-whl
+ git config --local user.name "sglang-bot"
+ git config --local user.email "sglangbot@gmail.com"
+ env:
+ WHL_TOKEN: ${{ secrets.GH_PAT_FOR_WHL_RELEASE }}
+
+ - name: Set up Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.10"
+
+ - name: Update wheel index
+ run: |
+ python3 scripts/update_pr_whl_index.py \
+ --pr-number ${{ inputs.pr_number }} \
+ --commit-hash ${{ needs.build-pr-wheel.outputs.commit_hash }} \
+ --wheel-version ${{ needs.build-pr-wheel.outputs.wheel_version }} \
+ --build-date ${{ needs.build-pr-wheel.outputs.build_date }}
+
+ - name: Push wheel index
+ run: |
+ cd sgl-whl
+ git add -A
+ git diff --staged --quiet || git commit -m "Update PR wheel index for PR #${{ inputs.pr_number }} (commit ${{ needs.build-pr-wheel.outputs.commit_hash }})"
+ git push
diff --git a/scripts/update_pr_whl_index.py b/scripts/update_pr_whl_index.py
new file mode 100755
index 000000000..5e522ae47
--- /dev/null
+++ b/scripts/update_pr_whl_index.py
@@ -0,0 +1,183 @@
+#!/usr/bin/env python3
+"""
+Update the wheel index for PR SGLang releases.
+
+This script generates a single PyPI-compatible index.html file at pr/index.html
+containing all PR builds, ordered by PR number and commit count (newest first).
+
+Similar to update_nightly_whl_index.py but for PR builds.
+"""
+
+import argparse
+import hashlib
+import pathlib
+import re
+
+
+def compute_sha256(file_path: pathlib.Path) -> str:
+ """Compute SHA256 hash of a file."""
+ sha256_hash = hashlib.sha256()
+ with open(file_path, "rb") as f:
+ for byte_block in iter(lambda: f.read(4096), b""):
+ sha256_hash.update(byte_block)
+ return sha256_hash.hexdigest()
+
+
+def update_wheel_index(
+ pr_number: str, commit_hash: str, wheel_version: str, build_date: str
+):
+ """Update the wheel index for PR releases.
+
+ Creates a single index at pr/index.html containing all PR builds.
+
+ Args:
+ pr_number: PR number (e.g., '123')
+ commit_hash: Short git commit hash (e.g., 'c5f1e86')
+ wheel_version: Full wheel version string (e.g., '0.5.6.dev7716+pr-123.gc5f1e86')
+ build_date: Build date in YYYY-MM-DD format (e.g., '2025-12-13')
+ """
+ dist_dir = pathlib.Path("dist")
+ whl_repo_dir = pathlib.Path("sgl-whl")
+
+ if not dist_dir.exists():
+ print(f"Warning: {dist_dir} does not exist, skipping index update")
+ return
+
+ # Base URL for wheels stored in GitHub Releases
+ base_url = "https://github.com/sgl-project/whl/releases/download"
+ release_tag = f"pr-{pr_number}-{build_date}-{commit_hash}"
+
+ # Create pr directory structure following PEP 503
+ # /pr/index.html -> links to sglang/
+ # /pr/sglang/index.html -> contains wheel links
+ pr_dir = whl_repo_dir / "pr"
+ pr_dir.mkdir(parents=True, exist_ok=True)
+
+ sglang_dir = pr_dir / "sglang"
+ sglang_dir.mkdir(parents=True, exist_ok=True)
+
+ root_index = pr_dir / "index.html"
+ package_index = sglang_dir / "index.html"
+
+ print(f"\nUpdating PR wheel index")
+ print(f" Root index: {root_index}")
+ print(f" Package index: {package_index}")
+
+ # Read existing package index if it exists
+ existing_links = []
+ if package_index.exists():
+ with open(package_index, "r") as f:
+ content = f.read()
+ # Extract existing links (skip header and HTML boilerplate)
+ existing_links = [
+ line for line in content.split("\n") if line.startswith("{filename}
'
+
+ new_links.append(link)
+ print(f" Added: {filename}")
+ except Exception as e:
+ print(f" Error processing {wheel_path.name}: {e}")
+ continue
+
+ if not new_links:
+ print(" No new wheels to add")
+ return
+
+ # Combine existing and new links (new links first for latest)
+ all_links = new_links + existing_links
+
+ # Remove duplicates while preserving order (newer first)
+ seen = set()
+ unique_links = []
+ for link in all_links:
+ # Extract filename from link to check for duplicates
+ filename_match = re.search(r">([^<]+\.whl)", link)
+ if filename_match:
+ filename = filename_match.group(1)
+ if filename not in seen:
+ seen.add(filename)
+ unique_links.append(link)
+
+ # Write root index (links to sglang package directory)
+ with open(root_index, "w") as f:
+ f.write("\n")
+ f.write('sglang\n')
+
+ print(f" Written root index: {root_index}")
+
+ # Write package index in minimal format
+ with open(package_index, "w") as f:
+ f.write("\n")
+ f.write("