forked from Materials-Consortia/optimade-python-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
43 lines (34 loc) · 1.14 KB
/
tasks.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
import re
from invoke import task
from optimade import __version__
@task
def setver(c, patch=False, new_ver=""):
if (not patch and not new_ver) or (patch and new_ver):
raise Exception("Either use --patch or specify e.g. --full='x.y.z.")
if patch:
v = [int(x) for x in __version__.split(".")]
v[2] += 1
new_ver = ".".join(map(str, v))
with open("optimade/__init__.py", "r") as f:
lines = [
re.sub("__version__ = .+", '__version__ = "{}"'.format(new_ver), l.rstrip())
for l in f
]
with open("optimade/__init__.py", "w") as f:
f.write("\n".join(lines))
with open("setup.py", "r") as f:
lines = [
re.sub("version=([^,]+),", 'version="{}",'.format(new_ver), l.rstrip())
for l in f
]
with open("setup.py", "w") as f:
f.write("\n".join(lines))
print("Bumped version to {}".format(new_ver))
@task
def publish(c):
c.run("rm dist/*.*", warn=True)
c.run("python setup.py sdist bdist_wheel")
c.run("twine upload dist/*")
@task
def update_openapijson(c):
c.run("cp local_openapi.json openapi.json")