-
Notifications
You must be signed in to change notification settings - Fork 44
/
deploy.py
29 lines (21 loc) · 924 Bytes
/
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
import sh
import os
import re
commit_count = sh.git("rev-list", ["--all"]).count("\n")
with open("setup.py") as f:
setup = f.read()
setup = re.sub("MICRO_VERSION = '[0-9]+'", "MICRO_VERSION = '{}'".format(commit_count), setup)
major = re.search("MAJOR_VERSION = '([0-9]+)'", setup).groups()[0]
minor = re.search("MINOR_VERSION = '([0-9]+)'", setup).groups()[0]
micro = re.search("MICRO_VERSION = '([0-9]+)'", setup).groups()[0]
version = "{}.{}.{}".format(major, minor, micro)
with open("setup.py", "w") as f:
f.write(setup)
with open("sky/__init__.py") as f:
init = f.read()
with open("sky/__init__.py", "w") as f:
f.write(re.sub('__version__ = "[0-9.]+"', '__version__ = "{}"'.format(version), init))
py_version = "python3.7" if sh.which("python3.7") is not None else "python"
os.system("rm -rf dist/")
os.system("{} setup.py sdist bdist_wheel".format(py_version))
os.system("twine upload dist/*")