Skip to content

chore: Add version bump automation script#2519

Open
smamindl wants to merge 4 commits intomasterfrom
smamindl/add-version-bump-script
Open

chore: Add version bump automation script#2519
smamindl wants to merge 4 commits intomasterfrom
smamindl/add-version-bump-script

Conversation

@smamindl
Copy link
Collaborator

Summary

Adds \scripts/bump-version.py\ — a release automation tool that safely updates version strings across the repo during version bumps.

Problem

Version bumps currently require manual find-and-replace across the repo, which is error-prone:

  • Risk of corrupting similar versions (e.g., \1.0.115\ when bumping \1.0.11)
  • Risk of modifying \�ersioned_docs/\ (historical snapshots)
  • Risk of changing unrelated versions in \package.json\ (npm deps)

Solution

A Python script using word-boundary-aware regex ((?<!\d)1.0.11(?![\d.])) that:

  • Only matches exact versions — won't touch \1.0.115, \1.0.11.0, etc.
  • Skips protected paths — \�ersioned_docs/, \package.json, .git/, etc.
  • Dry-run mode — preview all changes before applying
  • Self-validating — runs regex safety checks before every execution

Usage

\\�ash

Preview changes

python scripts/bump-version.py --from 1.1.0 --to 1.1.1 --dry-run

Apply changes

python scripts/bump-version.py --from 1.1.0 --to 1.1.1
\\

Tested against this repo

  • Scans 957 files, correctly identifies 13 files with 68 replacements
  • \�ersioned_docs/\ untouched ✅
  • \package.json\ (npm deps) untouched ✅
  • Partial version matches (e.g., \1.0.115) untouched ✅
  • Internal versions (e.g., \1.0.11.0) untouched ✅

Adds scripts/bump-version.py for safely updating version strings across
the repo during releases. Uses word-boundary-aware regex to prevent
partial matches (e.g., won't corrupt 1.0.115 when bumping 1.0.11).

Features:
- Dry-run mode to preview changes
- Denylist for versioned_docs/, package.json, etc.
- Regex safety verification before applying
- Summary report of all changes

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings March 24, 2026 01:16
@github-actions
Copy link

Hey @smamindl 👋!
Thank you so much for contributing to our repository 🙌.
Someone from SynapseML Team will be reviewing this pull request soon.

We use semantic commit messages to streamline the release process.
Before your pull request can be merged, you should make sure your first commit and PR title start with a semantic prefix.
This helps us to create release messages and credit you for your hard work!

Examples of commit messages with semantic prefixes:

  • fix: Fix LightGBM crashes with empty partitions
  • feat: Make HTTP on Spark back-offs configurable
  • docs: Update Spark Serving usage
  • build: Add codecov support
  • perf: improve LightGBM memory usage
  • refactor: make python code generation rely on classes
  • style: Remove nulls from CNTKModel
  • test: Add test coverage for CNTKModel

To test your commit locally, please follow our guild on building from source.
Check out the developer guide for additional guidance on testing your change.

@github-actions
Copy link

github-actions bot commented Mar 24, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 437b62b.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a repo-wide version bump automation script (scripts/bump-version.py) intended to safely update SynapseML version strings across the repository while avoiding partial matches and protected paths (e.g., versioned_docs/, package.json).

Changes:

  • Introduces a Python CLI tool to search/replace exact version strings using a boundary-aware regex.
  • Adds denylist-based directory/file skipping, plus dry-run and verbose reporting modes.
  • Implements pre-run “regex safety checks” to validate matching behavior against edge cases.

Comment on lines +116 to +147
try:
content = file_path.read_text(encoding="utf-8")
except (UnicodeDecodeError, PermissionError):
return 0, []

matches = list(regex.finditer(content))
if not matches:
return 0, []

changes = []
lines = content.split("\n")
seen_lines = set()
for match in matches:
line_num = content[:match.start()].count("\n") + 1
if line_num not in seen_lines:
seen_lines.add(line_num)
line_text = lines[line_num - 1].strip()
# Truncate long lines, showing context around the version
if len(line_text) > 120:
idx = line_text.find(old_version)
if idx >= 0:
start = max(0, idx - 40)
end = min(len(line_text), idx + len(old_version) + 40)
line_text = "..." + line_text[start:end] + "..."
changes.append(f" L{line_num}: {line_text}")

count = len(matches)

if not dry_run:
new_content = regex.sub(new_version, content)
file_path.write_text(new_content, encoding="utf-8")

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Path.read_text() / write_text() in text mode will normalize line endings (e.g., CRLF -> LF) when rewriting files, which can create large noisy diffs unrelated to the version bump. Consider preserving original newlines (e.g., opening with newline='' and writing back with the same newline style, or operating on bytes while keeping the original line endings) so the script only changes the version string.

Copilot uses AI. Check for mistakes.
smamindl and others added 3 commits March 23, 2026 22:50
Use read_bytes/write_bytes instead of read_text/write_text to avoid
CRLF -> LF normalization that would create noisy diffs unrelated to
the version bump.

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants