-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use towncrier to manage release notes
- Loading branch information
Showing
8 changed files
with
122 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import re | ||
import subprocess | ||
|
||
|
||
def run_towncrier(tag): | ||
cmd = ("towncrier", "build", "--version", tag.strip("v")) | ||
|
||
return subprocess.call(cmd) | ||
|
||
|
||
def update_fallback_version_in_pyproject(tag, fname="pyproject.toml"): | ||
version = tag.strip("v").split(".") | ||
# Default to +1 on minor version | ||
major, minor = version[0], int(version[1]) + 1 | ||
|
||
with open(fname, "r") as file: | ||
lines = file.readlines() | ||
|
||
pattern = "fallback_version" | ||
new_version = f"{major}.{minor}.dev0" | ||
# Iterate through the lines and find the pattern | ||
for i, line in enumerate(lines): | ||
if re.search(pattern, line): | ||
lines[i] = f'{pattern} = "{new_version}"\n' | ||
break | ||
|
||
# Write the updated content back to the file | ||
with open(fname, "w") as file: | ||
file.writelines(lines) | ||
|
||
print( | ||
f"\nNew (fallback) dev version ({new_version}) written to `pyproject.toml`.\n" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Get tag argument | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("tag") | ||
args = parser.parse_args() | ||
tag = args.tag | ||
|
||
# Update release notes | ||
run_towncrier(tag) | ||
|
||
# Update fallback version for setuptools_scm | ||
update_fallback_version_in_pyproject(tag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix getting version from metadata |