Skip to content

Commit

Permalink
Make bump_version.py also bump the version in pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
i80and committed Feb 10, 2023
1 parent e11f4ea commit 8974cdd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "snooty"
version = "0.13.12.dev"
version = "0.13.16.dev"
description = ""
authors = ["MongoDB, inc. <andrew.aldridge@mongodb.com>"]
license = "Apache-2.0"
Expand Down
16 changes: 16 additions & 0 deletions tools/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
CHANGELOG_PATH = Path("CHANGELOG.md")
INCOMING_VERISON_PAT = re.compile(r"\d+\.\d+\.\d+")
PAT = re.compile(r'"(\d+\.\d+\.\S+)"')
PYPROJECT_VERSION_PAT = re.compile(
r"(?<=^version = )\"(\d+\.\d+\.\S+)\"$", re.MULTILINE
)
CHANGELOG_UNRELEASED_PAT = re.compile(
r"\n## \[Unreleased\](?P<unreleased>.*)(?=\n## )", re.DOTALL
)
Expand Down Expand Up @@ -91,6 +94,19 @@ def replace(match: Match[str]) -> str:
f.truncate(0)
f.write(data)

with Path("pyproject.toml").open("r+") as f:
data = f.read()
data, n_replaced = PYPROJECT_VERSION_PAT.subn(f'"{version_to_bump_to}"', data)
if n_replaced != 1:
print(
"Error bumping version: expected 1 version string in pyproject.toml",
file=sys.stderr,
)
sys.exit(1)
f.seek(0)
f.truncate(0)
f.write(data)

if version_to_bump_to is not None and ".dev" not in version_to_bump_to:
try:
new_changelog = release_changelog(
Expand Down

0 comments on commit 8974cdd

Please sign in to comment.