-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtasks.py
36 lines (29 loc) · 1.09 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
import re
from invoke import task
from mongogrant 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. --new-ver='x.y.z.")
if patch:
v = [int(x) for x in __version__.split(".")]
v[2] += 1
new_ver = ".".join(map(str, v))
with open("mongogrant/__init__.py", "r") as f:
lines = [re.sub('__version__ = .+',
'__version__ = "{}"'.format(new_ver),
l.rstrip()) for l in f]
with open("mongogrant/__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/*")