Skip to content

Commit c1ba987

Browse files
committed
updating release tool
1 parent 70b292b commit c1ba987

File tree

1 file changed

+42
-19
lines changed

1 file changed

+42
-19
lines changed

do_release.py

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,63 @@
44
from json import load, dump
55
from github_release import gh_release_create
66
from sys import exit
7+
from os import path
78
from argparse import ArgumentParser
89
from subprocess import run
10+
'''WARNING: IF YOU DO NOT UPDATE YOUR README.md USING generate_plugininfo.py
11+
THIS PLUGIN WILL OVERWRITE IT!'''
912

1013
parser = ArgumentParser()
1114
parser.add_argument("-d", "--description", help="Description for the new release", action="store", dest="description", default="")
12-
parser.parse_args()
15+
parser.add_argument("-v", "--version", help="New version string", action="store", dest="new_version", default="")
16+
parser.add_argument("--force", help="Override the repository dirty check", action="store_true", dest="dirtyoverride", default=False)
17+
args = parser.parse_args()
18+
#TODO
1319

1420
repo = Repo(".")
1521
reponame = list(repo.remotes.origin.urls)[0].split(':')[1].split('.')[0]
22+
if repo.is_dirty() and not args.dirtyoverride:
23+
print("Cowardly refusing to do anything as the plugin repository is currently dirty.")
24+
exit(-1)
25+
26+
if not path.isfile("./generate_plugininfo.py"):
27+
print("Missing ./generate_plugininfo.py.")
28+
exit(-1)
1629

1730
with open('plugin.json') as plugin:
1831
data = load(plugin)
1932

33+
def update_version(data):
34+
print(f"Updating plugin with new version {data['version']}")
35+
with open('plugin.json', 'w') as plugin:
36+
dump(data, plugin)
37+
run(["./generate_plugininfo.py", "-r", "-f"], check=True)
38+
repo.index.add('plugin.json')
39+
repo.index.add('README.md')
40+
if args.description == "":
41+
repo.index.commit(f"Updating to {data['version']}")
42+
else:
43+
repo.index.commit(args.description)
44+
repo.git.push('origin')
45+
2046
for tag in repo.tags:
2147
if tag.name == data['version']:
22-
print(f"Current plugin version {data['version']} is already a tag. Shall I increment it for you?")
23-
yn = input("[y/n]: ")
24-
if yn == "Y" or yn == "y":
25-
digits = data['version'].split('.')
26-
newlast = str(int(digits[-1])+1)
27-
digits[-1] = newlast
28-
new_version = '.'.join(digits)
29-
data['version'] = new_version
30-
print(f"Updating plugin with new version {new_version}")
31-
with open('plugin.json', 'w') as plugin:
32-
dump(data, plugin)
33-
run(["./generate_plugininfo.py", "-r", "-f"], check=True)
34-
repo.index.add('plugin.json')
35-
repo.index.add('README.md')
36-
repo.index.commit(f"Updating to {new_version}")
37-
repo.git.push('origin')
48+
if args.new_version == "":
49+
print(f"Current plugin version {data['version']} is already a tag. Shall I increment it for you?")
50+
yn = input("[y/n]: ")
51+
if yn == "Y" or yn == "y":
52+
digits = data['version'].split('.')
53+
newlast = str(int(digits[-1])+1)
54+
digits[-1] = newlast
55+
inc_version = '.'.join(digits)
56+
data['version'] = inc_version
57+
update_version(data)
58+
else:
59+
print("Stopping...")
60+
exit(-1)
3861
else:
39-
print("Stopping...")
40-
exit(-1)
62+
data['version'] = args.new_version
63+
update_version(data)
4164

4265
# Create new tag
4366
new_tag = repo.create_tag(data['version'])

0 commit comments

Comments
 (0)