139 lines
4.6 KiB
YAML
139 lines
4.6 KiB
YAML
name: Release PyPI Nightly Wheels
|
|
|
|
on:
|
|
# Run daily at 2 AM UTC
|
|
schedule:
|
|
- cron: '0 2 * * *'
|
|
# Triggered by nightly Docker workflow to use same commit
|
|
repository_dispatch:
|
|
types: [nightly-release]
|
|
# Manual trigger for testing
|
|
workflow_dispatch:
|
|
inputs:
|
|
commit_sha:
|
|
description: 'Specific commit SHA to build (leave empty for latest)'
|
|
required: false
|
|
type: string
|
|
|
|
concurrency:
|
|
group: release-pypi-nightly-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-nightly-wheel:
|
|
if: github.repository == 'sgl-project/sglang'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
nightly_version: ${{ steps.build.outputs.nightly_version }}
|
|
commit_hash: ${{ steps.build.outputs.commit_hash }}
|
|
build_date: ${{ steps.build.outputs.build_date }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
# Use commit from: 1) Docker workflow, 2) manual input, 3) latest main
|
|
ref: ${{ github.event.client_payload.commit_sha || inputs.commit_sha || github.sha }}
|
|
fetch-depth: 0 # Need full history for setuptools-scm
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.10"
|
|
|
|
- name: Install build dependencies
|
|
run: |
|
|
pip install build wheel setuptools setuptools-scm
|
|
|
|
- name: Build wheel
|
|
id: build
|
|
run: |
|
|
cd python
|
|
cp ../README.md ../LICENSE .
|
|
|
|
# Build wheel - setuptools-scm automatically generates version from git tags
|
|
python3 -m build --wheel
|
|
|
|
# Extract version from built wheel filename
|
|
WHEEL_FILE=$(ls dist/*.whl)
|
|
NIGHTLY_VERSION=$(echo "$WHEEL_FILE" | sed 's/.*sglang-\(.*\)-py3.*/\1/')
|
|
|
|
# Get commit info
|
|
COMMIT_HASH=$(git rev-parse --short HEAD)
|
|
BUILD_DATE=$(date -u +%Y-%m-%d)
|
|
|
|
echo "Built wheel: $WHEEL_FILE"
|
|
echo "Nightly version: ${NIGHTLY_VERSION}"
|
|
echo "Commit: ${COMMIT_HASH}"
|
|
echo "Build date: ${BUILD_DATE}"
|
|
|
|
echo "nightly_version=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
|
|
echo "commit_hash=${COMMIT_HASH}" >> $GITHUB_OUTPUT
|
|
echo "build_date=${BUILD_DATE}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Upload wheel artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nightly-wheel
|
|
path: python/dist/*.whl
|
|
retention-days: 7
|
|
|
|
release-nightly:
|
|
needs: build-nightly-wheel
|
|
runs-on: ubuntu-latest
|
|
environment: 'prod'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download wheel artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: nightly-wheel
|
|
path: dist/
|
|
|
|
- name: List downloaded wheels
|
|
run: |
|
|
echo "Downloaded wheel:"
|
|
ls -lh dist/
|
|
|
|
- name: Create GitHub Release for nightly wheel
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: nightly-${{ needs.build-nightly-wheel.outputs.build_date }}-${{ needs.build-nightly-wheel.outputs.commit_hash }}
|
|
name: Nightly Build ${{ needs.build-nightly-wheel.outputs.build_date }} (${{ needs.build-nightly-wheel.outputs.commit_hash }})
|
|
repository: sgl-project/whl
|
|
token: ${{ secrets.GH_PAT_FOR_WHL_RELEASE }}
|
|
prerelease: true
|
|
body: |
|
|
Nightly build from commit ${{ github.sha }}
|
|
Build date: ${{ needs.build-nightly-wheel.outputs.build_date }}
|
|
Version: ${{ needs.build-nightly-wheel.outputs.nightly_version }}
|
|
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_nightly_whl_index.py \
|
|
--commit-hash ${{ needs.build-nightly-wheel.outputs.commit_hash }} \
|
|
--nightly-version ${{ needs.build-nightly-wheel.outputs.nightly_version }} \
|
|
--build-date ${{ needs.build-nightly-wheel.outputs.build_date }}
|
|
|
|
- name: Push wheel index
|
|
run: |
|
|
cd sgl-whl
|
|
git add -A
|
|
git diff --staged --quiet || git commit -m "Update nightly wheel index for commit ${{ needs.build-nightly-wheel.outputs.commit_hash }}"
|
|
git push
|