forked from IHCantabria/NetcdfData.Microservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.py
84 lines (48 loc) · 1.7 KB
/
deploy.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import toml
import argparse
parser = argparse.ArgumentParser()
# Add a new argument to the parser for major version
parser.add_argument("--major", action="store_true")
# Add a new argument to the parser for minor version
parser.add_argument("--minor", action="store_true")
# Add a new argument to the parser for patch version
parser.add_argument("--patch", action="store_true")
args = parser.parse_args()
# Read version from pyproject.toml
with open("pyproject.toml") as f:
config = toml.load(f)
version = config["project"]["version"]
# Update major version
if args.major:
version = version.split(".")
version[0] = str(int(version[0]) + 1)
version[1] = "0"
version[2] = "0"
version = ".".join(version)
# Update minor version
if args.minor:
version = version.split(".")
version[1] = str(int(version[1]) + 1)
version[2] = "0"
version = ".".join(version)
# Update patch version
if args.patch:
version = version.split(".")
version[2] = str(int(version[2]) + 1)
version = ".".join(version)
# Create a new tag with the new version
import os
# Check if there are any changes in the repository
if os.system("git diff-index --quiet HEAD --") != 0:
print("There are changes in the repository. Please commit them before deploying.")
exit(1)
# Write new version to pyproject.toml
config["project"]["version"] = version
with open("pyproject.toml", "w") as f:
toml.dump(config, f)
# Commit changes and create a new tag
os.system("git add pyproject.toml")
os.system("git commit -m 'Bump version to {0}'".format(version))
os.system("git tag -a {0} -m 'Version {0}'".format(version))
os.system("git push origin tag {0}".format(version))
os.system("git push")