From 53529f46ccc9554e8426bcfa6d666af4b0db8d6a Mon Sep 17 00:00:00 2001 From: Kangyan-Zhou Date: Sun, 19 Oct 2025 18:10:26 -0700 Subject: [PATCH] Fix version bump script to handle TOML files with outdated versions (#11787) Co-authored-by: Claude --- scripts/release/bump_sglang_version.py | 1 - scripts/release/utils.py | 47 +++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/scripts/release/bump_sglang_version.py b/scripts/release/bump_sglang_version.py index b0ec343e8..11f023d29 100755 --- a/scripts/release/bump_sglang_version.py +++ b/scripts/release/bump_sglang_version.py @@ -19,7 +19,6 @@ def main(): 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"), diff --git a/scripts/release/utils.py b/scripts/release/utils.py index efbed9ef6..120470593 100644 --- a/scripts/release/utils.py +++ b/scripts/release/utils.py @@ -92,7 +92,16 @@ def replace_in_file(file_path: Path, old_version: str, new_version: str) -> bool return False content = file_path.read_text() - new_content = content.replace(old_version, new_version) + + # For TOML files, use regex to match version field regardless of current value + if file_path.suffix == ".toml": + # Match: version = "X.Y.Z..." (with optional quotes and whitespace) + # Captures quotes (or lack thereof) to preserve original quoting style + pattern = r'(version\s*=\s*)(["\']?)([^"\'\n]+)(["\']?)' + new_content = re.sub(pattern, rf"\g<1>\g<2>{new_version}\g<4>", content) + else: + # For non-TOML files, use simple string replacement + new_content = content.replace(old_version, new_version) if content == new_content: print(f"No changes needed in {file_path}") @@ -150,3 +159,39 @@ def bump_version( print() print(f"Successfully updated {updated_count} file(s)") print(f"Version bumped from {old_version} to {new_version}") + + # Validate that all files now contain the new version + print("\nValidating version updates...") + failed_files = [] + for file_rel in files_to_update: + file_abs = repo_root / file_rel + if not file_abs.exists(): + print(f"Warning: File {file_rel} does not exist, skipping validation.") + continue + + content = file_abs.read_text() + + # For TOML files, use regex to specifically check the version field + if file_abs.suffix == ".toml": + # Match version field with optional quotes + pattern = r'version\s*=\s*["\']?' + re.escape(new_version) + r'["\']?' + if not re.search(pattern, content): + failed_files.append(file_rel) + print(f"✗ {file_rel} does not contain version {new_version}") + else: + print(f"✓ {file_rel} validated") + else: + # For non-TOML files, use simple string search + if new_version not in content: + failed_files.append(file_rel) + print(f"✗ {file_rel} does not contain version {new_version}") + else: + print(f"✓ {file_rel} validated") + + if failed_files: + print(f"\nError: {len(failed_files)} file(s) were not updated correctly:") + for file_rel in failed_files: + print(f" - {file_rel}") + sys.exit(1) + + print("\nAll files validated successfully!")