Skip to content

Commit

Permalink
Update scripts/release_scripts/increment_version.py
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
SafetyQuincyF and coderabbitai[bot] authored Oct 23, 2024
1 parent 644fee9 commit b9d5e93
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scripts/release_scripts/increment_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ def get_current_version(file_path: str) -> str:

def get_last_version_from_changelog(file_path: str) -> str:
"""Extract the last version noted in the CHANGELOG.MD file."""
with open(file_path, "r") as file:
content = file.read()
match = re.search(r"\[(\d+\.\d+\.\d+)\] - \d{4}-\d{2}-\d{2}", content)
return match.group(1) if match else None
try:
with open(file_path, "r") as file:
content = file.read()
except FileNotFoundError:
raise FileNotFoundError(f"Changelog file not found: {file_path}")
except IOError as e:
raise IOError(f"Error reading changelog file: {e}")

# More strict regex pattern for semantic versioning
match = re.search(r"\[(\d+\.\d+\.\d+)\] - (?:\d{4})-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])", content)
if not match:
raise ValueError("No valid version entry found in changelog")
return match.group(1)


def increment_version(version: str, bump_type: str) -> str:
Expand Down

0 comments on commit b9d5e93

Please sign in to comment.