Unverified Commit 53529f46 authored by Kangyan-Zhou's avatar Kangyan-Zhou Committed by GitHub
Browse files

Fix version bump script to handle TOML files with outdated versions (#11787)


Co-authored-by: default avatarClaude <noreply@anthropic.com>
parent 24ed3f32
......@@ -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"),
......
......@@ -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!")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment