MCPcopy Create free account
hub / github.com/apache/singa / main

Function main

tool/release/release.py:35–109  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

33
34
35def main(args):
36 # current version
37 last_tag = subprocess.run(
38 ['git', 'describe', '--abbrev=0', '--tags'],
39 stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
40 # last_tag="4.2.3-rc1"
41 # last_tag="3.2.1"
42 tags = re.split("\.|-rc", last_tag)
43 new_tags = [int(i) for i in tags]
44
45 # parse args
46 parser = argparse.ArgumentParser()
47 parser.add_argument(
48 '-y',
49 default=False,
50 dest='confirmed',
51 action='store_true',
52 help="In interactive mode, for user to confirm. Could be used in script")
53 parser.add_argument('type',
54 choices=['major', 'minor', 'patch', 'rc', 'stable'],
55 help="Release types")
56 args = parser.parse_args(args)
57
58 # check eligibility of arg
59 if args.type in ['major', 'minor', 'patch']:
60 if len(tags) == 4:
61 exit("Current type \"%s\" is not allowed in pre release(version %s)"
62 % (args.type, last_tag))
63 if args.type in ['stable', 'rc']:
64 if len(tags) == 3:
65 exit(
66 "Current type \"%s\" is not allowed in stable release(version %s)"
67 % (args.type, last_tag))
68
69 # new version
70 if args.type == 'major':
71 new_tags[0] += 1
72 new_tags[1] = 0
73 new_tags[2] = 0
74 new_tags.append(0)
75 elif args.type == 'minor':
76 new_tags[1] += 1
77 new_tags[2] = 0
78 new_tags.append(0)
79 elif args.type == 'patch':
80 new_tags[2] += 1
81 new_tags.append(0)
82 elif args.type == 'stable':
83 new_tags.pop(-1)
84 elif args.type == 'rc':
85 new_tags[3] += 1
86
87 # ask for confirmation
88 print("Please confirm bumping version from %s to %s" %
89 (last_tag, tag_string(new_tags)))
90 ans = "y" if args.confirmed else ""
91 while ans not in ['y', 'n']:
92 ans = input("OK to continue [Y/N]? ").lower()

Callers 1

release.pyFile · 0.70

Calls 3

tag_stringFunction · 0.85
appendMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected