Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/release/bump_sglang_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
47 changes: 46 additions & 1 deletion scripts/release/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The continue statement skips non-existent files, but this might hide potential issues. It would be better to log a warning or error message to inform the user that a file specified for update does not exist. This can help in debugging configuration issues.

if not file_abs.exists():
    print(f"Warning: File {file_rel} does not exist, skipping validation.")
    continue  # Skip non-existent files (already warned above)

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!")
Loading