initial commit for GitHub
This commit is contained in:
43
server/app/scripts/bump.py
Executable file
43
server/app/scripts/bump.py
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
from subprocess import run
|
||||
|
||||
UTF8 = "utf-8"
|
||||
|
||||
|
||||
def bump():
|
||||
tags = [int(tag) for tag in find_tags() if tag.isnumeric()]
|
||||
tag_name = max(tags) + 1
|
||||
cmds = [f"git tag {tag_name}", f"git push origin tag {tag_name}"]
|
||||
for cmd in cmds:
|
||||
cmd = cmd.split(" ")
|
||||
output = run(cmd, capture_output=True, encoding=UTF8)
|
||||
if output.stdout:
|
||||
print(output.stdout)
|
||||
if output.stderr:
|
||||
print(output.stderr)
|
||||
|
||||
|
||||
def find_tags() -> list[str]:
|
||||
dot_git = find_git_dir()
|
||||
tags_dir = dot_git / "refs" / "tags"
|
||||
for _, _, files in tags_dir.walk():
|
||||
return files
|
||||
raise Exception("Error parsing tags")
|
||||
|
||||
|
||||
def find_git_dir() -> Path:
|
||||
dot_git = ".git"
|
||||
|
||||
def _find_git_dir(cwd: Path = Path(__file__)) -> Path:
|
||||
for _, dirs, _ in cwd.walk(top_down=False):
|
||||
if dot_git in dirs:
|
||||
return cwd / dot_git
|
||||
return _find_git_dir(cwd.parent)
|
||||
|
||||
return _find_git_dir()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
bump()
|
||||
Reference in New Issue
Block a user