aboutsummaryrefslogtreecommitdiffstats
path: root/.hooks/make_release_commit.py
diff options
context:
space:
mode:
Diffstat (limited to '.hooks/make_release_commit.py')
-rw-r--r--.hooks/make_release_commit.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/.hooks/make_release_commit.py b/.hooks/make_release_commit.py
index 3097ebb..2934cd2 100644
--- a/.hooks/make_release_commit.py
+++ b/.hooks/make_release_commit.py
@@ -1,20 +1,32 @@
#!/usr/bin/env python3
import tomli
+import secrets
import subprocess
from pathlib import Path
+
def create_release_commit():
cwd = Path.cwd()
- with open(cwd / 'pyproject.toml', 'rb') as file:
+ with open(cwd / "pyproject.toml", "rb") as file:
pyproject = tomli.load(file)
- version = pyproject['tool']['poetry']['version']
+ version = pyproject["tool"]["poetry"]["version"]
+ branch = f"release-{version}-{secrets.token_hex(12)}"
- p = subprocess.Popen(f'git add . && git commit -m "Release version {version}" && git tag -a "{version}" -m "Release version {version}" && git push && git push --tags',
- shell=True,
- cwd=cwd)
+ p = subprocess.Popen(
+ " && ".join[
+ f"git checkout -b {branch}",
+ "git add .",
+ f'git commit -m "Release version {version}"',
+ f'git tag -a "{version}" -m "Release version {version}"',
+ f"git push --set-upstream origin {branch}",
+ f"git push --tags",
+ ],
+ shell=True,
+ cwd=cwd,
+ )
p.wait()
-if __name__ == '__main__':
- create_release_commit()
+if __name__ == "__main__":
+ create_release_commit()