diff --git a/.github/workflows/bot-bump-kernel-version.yml b/.github/workflows/bot-bump-kernel-version.yml new file mode 100644 index 000000000..baebca87b --- /dev/null +++ b/.github/workflows/bot-bump-kernel-version.yml @@ -0,0 +1,84 @@ +name: Bot Bump Kernel Version + +on: + workflow_dispatch: + inputs: + new_version: + description: 'New sgl-kernel version (e.g., 0.3.12)' + required: true + type: string + +permissions: + contents: write + pull-requests: write + +jobs: + bump-kernel-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Configure Git + run: | + git config user.name "sglang-bot" + git config user.email "sglang-bot@users.noreply.github.com" + + - name: Create new branch + run: | + BRANCH_NAME="bot/bump-kernel-version-${{ github.event.inputs.new_version }}" + git checkout -b "$BRANCH_NAME" + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + + - name: Run kernel version bump script + run: | + python scripts/release/bump_kernel_version.py "${{ github.event.inputs.new_version }}" + + - name: Commit changes + run: | + git add -A + git commit -m "chore: bump sgl-kernel version to ${{ github.event.inputs.new_version }} + + This commit updates the sgl-kernel version across all relevant files: + - sgl-kernel/pyproject.toml + - sgl-kernel/pyproject_cpu.toml + - sgl-kernel/pyproject_rocm.toml + - sgl-kernel/python/sgl_kernel/version.py + + 🤖 Generated with GitHub Actions" + + - name: Push changes + run: | + git push origin "$BRANCH_NAME" + + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --title "chore: bump sgl-kernel version to ${{ github.event.inputs.new_version }}" \ + --body "## Summary + + This PR bumps the sgl-kernel version to \`${{ github.event.inputs.new_version }}\` across all relevant files. + + ## Files Updated + - sgl-kernel/pyproject.toml + - sgl-kernel/pyproject_cpu.toml + - sgl-kernel/pyproject_rocm.toml + - sgl-kernel/python/sgl_kernel/version.py + + ## Testing + - [ ] Verify all version strings are updated correctly + - [ ] Test kernel installation with new version + - [ ] Run CI tests + + 🤖 Generated with GitHub Actions" \ + --base main \ + --head "$BRANCH_NAME" diff --git a/.github/workflows/bot-bump-sglang-version.yml b/.github/workflows/bot-bump-sglang-version.yml new file mode 100644 index 000000000..f06dbd85f --- /dev/null +++ b/.github/workflows/bot-bump-sglang-version.yml @@ -0,0 +1,94 @@ +name: Bot Bump SGLang Version + +on: + workflow_dispatch: + inputs: + new_version: + description: 'New SGLang version (e.g., 0.5.3 or 0.5.3rc0)' + required: true + type: string + +permissions: + contents: write + pull-requests: write + +jobs: + bump-sglang-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Configure Git + run: | + git config user.name "sglang-bot" + git config user.email "sglang-bot@users.noreply.github.com" + + - name: Create new branch + run: | + BRANCH_NAME="bot/bump-sglang-version-${{ github.event.inputs.new_version }}" + git checkout -b "$BRANCH_NAME" + echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV + + - name: Run SGLang version bump script + run: | + python scripts/release/bump_sglang_version.py "${{ github.event.inputs.new_version }}" + + - name: Commit changes + run: | + git add -A + git commit -m "chore: bump SGLang version to ${{ github.event.inputs.new_version }} + + This commit updates the SGLang version across all relevant files: + - Makefile + - benchmark/deepseek_v3/README.md + - docker/Dockerfile.rocm + - docs/get_started/install.md + - docs/platforms/amd_gpu.md + - docs/platforms/ascend_npu.md + - python/pyproject.toml + - python/pyproject_other.toml + - python/sglang/version.py + + 🤖 Generated with GitHub Actions" + + - name: Push changes + run: | + git push origin "$BRANCH_NAME" + + - name: Create Pull Request + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --title "chore: bump SGLang version to ${{ github.event.inputs.new_version }}" \ + --body "## Summary + + This PR bumps the SGLang version to \`${{ github.event.inputs.new_version }}\` across all relevant files. + + ## Files Updated + - Makefile + - benchmark/deepseek_v3/README.md + - docker/Dockerfile.rocm + - docs/get_started/install.md + - docs/platforms/amd_gpu.md + - docs/platforms/ascend_npu.md + - python/pyproject.toml + - python/pyproject_other.toml + - python/sglang/version.py + + ## Testing + - [ ] Verify all version strings are updated correctly + - [ ] Test installation with new version + - [ ] Run CI tests + + 🤖 Generated with GitHub Actions" \ + --base main \ + --head "$BRANCH_NAME" diff --git a/scripts/release/README.md b/scripts/release/README.md new file mode 100644 index 000000000..f4196fdbd --- /dev/null +++ b/scripts/release/README.md @@ -0,0 +1,94 @@ +# Release Scripts + +This directory contains scripts to automate version bumping for SGLang releases. + +## Scripts + +### `bump_sglang_version.py` +Updates SGLang version across all relevant files following the pattern from [PR #10468](https://github.com/sgl-project/sglang/pull/10468). + +**Usage:** +```bash +python scripts/release/bump_sglang_version.py 0.5.3rc0 +``` + +**Files updated:** +- `Makefile` +- `benchmark/deepseek_v3/README.md` +- `docker/Dockerfile.rocm` +- `docs/get_started/install.md` +- `docs/platforms/amd_gpu.md` +- `docs/platforms/ascend_npu.md` +- `python/pyproject.toml` +- `python/pyproject_other.toml` +- `python/sglang/version.py` + +### `bump_kernel_version.py` +Updates sgl-kernel version across all relevant files following the pattern from [PR #10732](https://github.com/sgl-project/sglang/pull/10732). + +**Usage:** +```bash +python scripts/release/bump_kernel_version.py 0.3.12 +``` + +**Files updated:** +- `sgl-kernel/pyproject.toml` +- `sgl-kernel/pyproject_cpu.toml` +- `sgl-kernel/pyproject_rocm.toml` +- `sgl-kernel/python/sgl_kernel/version.py` + +## Manual Testing Instructions + +### Test SGLang Version Bump + +1. **Run the script:** + ```bash + python scripts/release/bump_sglang_version.py 0.5.4rc0 + ``` + +2. **Verify changes with git diff:** + ```bash + git diff + ``` + +3. **Check specific files contain the new version:** + ```bash + grep -r "0.5.4rc0" python/sglang/version.py + grep -r "0.5.4rc0" python/pyproject.toml + grep -r "0.5.4rc0" docs/get_started/install.md + ``` + +4. **Reset changes (if testing):** + ```bash + git checkout . + ``` + +### Test Kernel Version Bump + +1. **Run the script:** + ```bash + python scripts/release/bump_kernel_version.py 0.3.13 + ``` + +2. **Verify changes with git diff:** + ```bash + git diff + ``` + +3. **Check specific files contain the new version:** + ```bash + grep -r "0.3.13" sgl-kernel/python/sgl_kernel/version.py + grep -r "0.3.13" sgl-kernel/pyproject.toml + ``` + +4. **Reset changes (if testing):** + ```bash + git checkout . + ``` + +## Version Format Validation + +- **SGLang versions:** `X.Y.Z` or `X.Y.ZrcN` (e.g., `0.5.3` or `0.5.3rc0`) +- **Kernel versions:** `X.Y.Z` (e.g., `0.3.12`) + +The scripts will validate the version format and exit with an error if invalid. diff --git a/scripts/release/bump_kernel_version.py b/scripts/release/bump_kernel_version.py new file mode 100755 index 000000000..d8aee551a --- /dev/null +++ b/scripts/release/bump_kernel_version.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import argparse +from pathlib import Path + +from utils import bump_version + + +def main(): + parser = argparse.ArgumentParser( + description="Bump sgl-kernel version across all relevant files" + ) + parser.add_argument("new_version", help="New version (e.g., 0.3.12)") + args = parser.parse_args() + + version_file = Path("sgl-kernel/python/sgl_kernel/version.py") + + files_to_update = [ + Path("docker/Dockerfile"), + Path("sgl-kernel/pyproject.toml"), + Path("sgl-kernel/pyproject_cpu.toml"), + Path("sgl-kernel/pyproject_rocm.toml"), + Path("sgl-kernel/python/sgl_kernel/version.py"), + ] + + bump_version(args.new_version, version_file, files_to_update, "kernel") + + +if __name__ == "__main__": + main() diff --git a/scripts/release/bump_sglang_version.py b/scripts/release/bump_sglang_version.py new file mode 100755 index 000000000..604dc2075 --- /dev/null +++ b/scripts/release/bump_sglang_version.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +import argparse +from pathlib import Path + +from utils import bump_version + + +def main(): + parser = argparse.ArgumentParser( + description="Bump SGLang version across all relevant files" + ) + parser.add_argument("new_version", help="New version (e.g., 0.5.3 or 0.5.3rc0)") + args = parser.parse_args() + + version_file = Path("python/sglang/version.py") + + files_to_update = [ + Path("Makefile"), + Path("benchmark/deepseek_v3/README.md"), + Path("docker/Dockerfile.rocm"), + Path("docs/get_started/install.md"), + Path("docs/platforms/amd_gpu.md"), + Path("docs/platforms/ascend_npu.md"), + Path("python/pyproject.toml"), + Path("python/pyproject_other.toml"), + Path("python/sglang/version.py"), + ] + + bump_version(args.new_version, version_file, files_to_update, "sglang") + + +if __name__ == "__main__": + main() diff --git a/scripts/release/utils.py b/scripts/release/utils.py new file mode 100644 index 000000000..82897ce6d --- /dev/null +++ b/scripts/release/utils.py @@ -0,0 +1,93 @@ +import re +import sys +from pathlib import Path +from typing import List, Tuple + + +def normalize_version(version: str) -> str: + """Remove 'v' prefix from version string if present.""" + return version.lstrip("v") + + +def validate_version(version: str, version_type: str = "sglang") -> bool: + if version_type == "sglang": + pattern = r"^\d+\.\d+\.\d+(rc\d+)?$" + else: + pattern = r"^\d+\.\d+\.\d+$" + + if not re.match(pattern, version): + return False + return True + + +def get_repo_root() -> Path: + return Path(__file__).parent.parent.parent + + +def read_current_version(version_file: Path) -> str: + content = version_file.read_text() + match = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', content) + if not match: + raise ValueError(f"Could not find version in {version_file}") + return match.group(1) + + +def replace_in_file(file_path: Path, old_version: str, new_version: str) -> bool: + if not file_path.exists(): + print(f"Warning: {file_path} does not exist, skipping") + return False + + content = file_path.read_text() + new_content = content.replace(old_version, new_version) + + if content == new_content: + print(f"No changes needed in {file_path}") + return False + + file_path.write_text(new_content) + print(f"✓ Updated {file_path}") + return True + + +def bump_version( + new_version: str, + version_file: Path, + files_to_update: List[Path], + version_type: str = "sglang", +) -> None: + # Normalize version (remove 'v' prefix if present) + new_version = normalize_version(new_version) + + if not validate_version(new_version, version_type): + print(f"Error: Invalid version format: {new_version}") + if version_type == "sglang": + print("Expected format: X.Y.Z or X.Y.ZrcN (e.g., 0.5.3 or 0.5.3rc0)") + else: + print("Expected format: X.Y.Z (e.g., 0.3.12)") + sys.exit(1) + + repo_root = get_repo_root() + version_file_abs = repo_root / version_file + + if not version_file_abs.exists(): + print(f"Error: Version file {version_file_abs} does not exist") + sys.exit(1) + + old_version = read_current_version(version_file_abs) + print(f"Current version: {old_version}") + print(f"New version: {new_version}") + print() + + if old_version == new_version: + print("Warning: New version is the same as current version") + sys.exit(0) + + updated_count = 0 + for file_rel in files_to_update: + file_abs = repo_root / file_rel + if replace_in_file(file_abs, old_version, new_version): + updated_count += 1 + + print() + print(f"Successfully updated {updated_count} file(s)") + print(f"Version bumped from {old_version} to {new_version}")