-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcreate_tag_release.py
51 lines (39 loc) · 1.73 KB
/
create_tag_release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import subprocess
import tapuino_common as tc
version_file_name = 'version'
try:
cur_branch = tc.git_check("branch", "--no-color", "--show-current")
if cur_branch != "main":
tc.pretty_exit_error("This script must be run on the 'main' branch, you are on: " + cur_branch)
print("On the 'main' branch, proceeding...")
while True:
changes_pending = tc.git_check("status", "--porcelain")
if changes_pending == "":
print("No pending changes, proceeding...")
break
print("You have the following unstaged or uncommitted files:\n" + changes_pending)
if tc.get_confirmation("Would you like to commit these changes?"):
tc.git_check("commit", "-a", "-v")
else:
tc.pretty_exit_error("Quitting due to pending changes")
while True:
not_synced = tc.git_check("cherry", "-v")
if not_synced == "":
print("No pending commits, proceeding...")
break
print("The following commits have not been pushed to main:\n" + not_synced)
if tc.get_confirmation("Would you like to push these commits?"):
tc.git_check("push", "origin", "main")
else:
tc.pretty_exit_error("Quitting due to pending commits")
print("Everything seems to be ready for a release, let's go!")
try:
with open(version_file_name) as versionFile:
version = versionFile.readline().strip()
except:
tc.pretty_exit_error("Missing 'version' file! Exiting!\n")
subprocess.check_output(["git", "tag", version, "main"])
subprocess.check_output(["git", "push", "origin", version])
except Exception as e:
print("Something went wrong here!\n")
tc.pretty_exit_error(e)