forked from materialsproject/emmet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
41 lines (34 loc) · 1.27 KB
/
Copy pathtasks.py
File metadata and controls
41 lines (34 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
from datetime import date
import re
from invoke import task
from emmet import __version__
@task
def setver(c):
# Calendar versioning (https://calver.org/), with a patch segment
# for release of multiple version in a day (should be rare).
new_ver = date.today().isoformat().replace("-", ".")
if __version__.startswith(new_ver):
if __version__ == new_ver:
new_ver += ".1"
else:
year, month, day, patch = new_ver.split('.')
patch = str(int(patch) + 1)
new_ver = ".".join(year, month, day, patch)
with open("emmet/__init__.py", "r") as f:
lines = [re.sub('__version__ = .+',
'__version__ = "{}"'.format(new_ver),
l.rstrip()) for l in f]
with open("emmet/__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/*")