forked from wandb/wandb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbumpversion-tool.py
More file actions
executable file
·72 lines (54 loc) · 1.9 KB
/
bumpversion-tool.py
File metadata and controls
executable file
·72 lines (54 loc) · 1.9 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
import argparse
import configparser
import sys
import bumpversion
parser = argparse.ArgumentParser()
parser.add_argument("--to-dev", action="store_true", help="bump the dev version")
parser.add_argument("--from-dev", action="store_true", help="bump the dev version")
parser.add_argument("--debug", action="store_true", help="debug")
args = parser.parse_args()
def version_problem(current_version):
print("Unhandled version string: {}".format(current_version))
sys.exit(1)
def bump_release_to_dev(current_version):
# Assume this is a released version
parts = current_version.split(".")
if len(parts) != 3:
version_problem(current_version)
major, minor, patch = parts
patch_num = 0
try:
patch_num = int(patch)
except ValueError:
version_problem(current_version)
new_version = "{}.{}.{}.dev1".format(major, minor, patch_num + 1)
bump_args = []
if args.debug:
bump_args += ["--allow-dirty", "--dry-run", "--verbose"]
bump_args += ["--new-version", new_version, "dev"]
bumpversion.main(bump_args)
def bump_release_from_dev(current_version):
# Assume this is a dev version
parts = current_version.split(".")
if len(parts) != 4:
version_problem(current_version)
major, minor, patch, _ = parts
new_version = "{}.{}.{}".format(major, minor, patch)
bump_args = []
if args.debug:
bump_args += ["--allow-dirty", "--dry-run", "--verbose"]
bump_args += ["--new-version", new_version, "patch"]
bumpversion.main(bump_args)
def main():
config = configparser.ConfigParser()
config.read("setup.cfg")
current_version = config["bumpversion"]["current_version"]
if args.to_dev:
bump_release_to_dev(current_version)
elif args.from_dev:
bump_release_from_dev(current_version)
else:
parser.print_help()
if __name__ == "__main__":
main()