Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bump_version.py also bump the version in pyproject.toml #445

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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