2021-05-01 12:23:38 +02:00
|
|
|
import argparse
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import toml
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
|
|
|
"rule",
|
|
|
|
help="either a semver string or a bump rule, will be passed to poetry",
|
|
|
|
)
|
2022-03-09 00:13:38 +01:00
|
|
|
parser.add_argument("--no-commit", dest="commit", action="store_false")
|
2021-05-01 12:23:38 +02:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
subprocess.run(["poetry", "version", args.rule], check=True)
|
|
|
|
|
|
|
|
with open("pyproject.toml") as f:
|
|
|
|
pyproject = toml.load(f)
|
|
|
|
|
|
|
|
version = pyproject["tool"]["poetry"]["version"]
|
2022-04-16 01:10:09 +02:00
|
|
|
repo_url = pyproject["tool"]["poetry"]["repository"]
|
2021-05-01 12:23:38 +02:00
|
|
|
|
|
|
|
with open("jubeatools/version.py", mode="w") as f:
|
|
|
|
f.write(f'__version__ = "{version}"\n')
|
2022-04-16 01:10:09 +02:00
|
|
|
f.write(f'__repository_url__ = "{repo_url}"\n')
|
2021-05-01 13:18:35 +02:00
|
|
|
|
|
|
|
if args.commit:
|
|
|
|
subprocess.run(["git", "reset"])
|
2021-05-06 15:12:12 +02:00
|
|
|
subprocess.run(
|
|
|
|
["git", "add", "pyproject.toml", "jubeatools/version.py"], check=True
|
|
|
|
)
|
2021-05-01 13:18:35 +02:00
|
|
|
subprocess.run(["git", "commit", "-m", f"Bump version to {version}"])
|
|
|
|
subprocess.run(["git", "tag", f"v{version}"])
|