Skip to content

Commit

Permalink
add create-tag.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchin committed Dec 20, 2023
1 parent 1502d85 commit 0a34928
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions scripts/create-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
import os
import subprocess
import sys

if len(sys.argv) != 2:
print("Usage: ./create-tag.py VERSION(such as 1.1.0)")
sys.exit(1)

new_version = sys.argv[1]

this_file_path = os.path.dirname(__file__)

# 1. update version number in gplately/__init__.py
# 2. commit change, create a tag and push changes and the new tag

lines = []
with open(f"{this_file_path}/../gplately/__init__.py", "r") as f:
for line in f:
if line.startswith("__version__"):
lines.append(f'__version__ = "{new_version}"\n')
else:
lines.append(line)

with open(f"{this_file_path}/../gplately/__init__.py", "w") as of:
of.writelines(lines)

subprocess.call(
["git", "add", f"{this_file_path}/../gplately/__init__.py"]
)
subprocess.call(["git", "commit", '-m"update version"'])
subprocess.call(["git", "push"])

subprocess.call(["git", "tag", "v" + new_version])
subprocess.call(["git", "push", "origin", "v" + new_version])

0 comments on commit 0a34928

Please sign in to comment.