Skip to content

Commit

Permalink
only replace first instance of version string in cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Apr 27, 2024
1 parent 1c92222 commit ead1f81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions increment_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def bump_version(major: int, minor: int, patch: int, part: str) -> str:

def update_cargo_toml(file_path: Path, new_version: str) -> None:
content = file_path.read_text()
content = re.sub(r'version = "(\d+\.\d+\.\d+)"', f'version = "{new_version}"', content)
content = re.sub(r'version = "(\d+\.\d+\.\d+)"', f'version = "{new_version}"', content, count=1)
file_path.write_text(content)


def update_changelog(file_path: Path, new_version: str) -> None:
today = datetime.datetime.now(tz=datetime.timezone.utc).strftime("%Y-%m-%d")
content = file_path.read_text()
new_section = f"## UNRELEASED\n\n## {new_version} ({today})"
content = content.replace("## UNRELEASED", new_section)
content = content.replace("## UNRELEASED", new_section, 1)
file_path.write_text(content)


Expand Down

0 comments on commit ead1f81

Please sign in to comment.