Skip to content

Commit 484c248

Browse files
authored
Make bump_version.py also bump the version in pyproject.toml (#445)
1 parent c3b763b commit 484c248

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "snooty"
3-
version = "0.13.12.dev"
3+
version = "0.13.16.dev"
44
description = ""
55
authors = ["MongoDB, inc. <[email protected]>"]
66
license = "Apache-2.0"

tools/bump_version.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
CHANGELOG_PATH = Path("CHANGELOG.md")
99
INCOMING_VERISON_PAT = re.compile(r"\d+\.\d+\.\d+")
1010
PAT = re.compile(r'"(\d+\.\d+\.\S+)"')
11+
PYPROJECT_VERSION_PAT = re.compile(
12+
r"(?<=^version = )\"(\d+\.\d+\.\S+)\"$", re.MULTILINE
13+
)
1114
CHANGELOG_UNRELEASED_PAT = re.compile(
1215
r"\n## \[Unreleased\](?P<unreleased>.*)(?=\n## )", re.DOTALL
1316
)
@@ -91,6 +94,19 @@ def replace(match: Match[str]) -> str:
9194
f.truncate(0)
9295
f.write(data)
9396

97+
with Path("pyproject.toml").open("r+") as f:
98+
data = f.read()
99+
data, n_replaced = PYPROJECT_VERSION_PAT.subn(f'"{version_to_bump_to}"', data)
100+
if n_replaced != 1:
101+
print(
102+
"Error bumping version: expected 1 version string in pyproject.toml",
103+
file=sys.stderr,
104+
)
105+
sys.exit(1)
106+
f.seek(0)
107+
f.truncate(0)
108+
f.write(data)
109+
94110
if version_to_bump_to is not None and ".dev" not in version_to_bump_to:
95111
try:
96112
new_changelog = release_changelog(

0 commit comments

Comments
 (0)