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
·54 lines (39 loc) · 1.27 KB
/
bumpversion-tool.py
File metadata and controls
executable file
·54 lines (39 loc) · 1.27 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
#!/usr/bin/env python
import argparse
import configparser
import sys
import bumpversion
parser = argparse.ArgumentParser()
parser.add_argument("--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"]
bump_args += ["--new-version", new_version, "dev"]
bumpversion.main(bump_args)
def main():
config = configparser.ConfigParser()
config.read("setup.cfg")
current_version = config["bumpversion"]["current_version"]
if args.dev:
bump_release_to_dev(current_version)
else:
parser.print_help()
if __name__ == "__main__":
main()