Conversation
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]>
|
Hey @smamindl 👋! We use semantic commit messages to streamline the release process. Examples of commit messages with semantic prefixes:
To test your commit locally, please follow our guild on building from source. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure 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 FilesNone |
There was a problem hiding this comment.
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.
| 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") | ||
|
|
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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]>
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:
Solution
A Python script using word-boundary-aware regex ((?<!\d)1.0.11(?![\d.])) that:
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