forked from materialsvirtuallab/flamyngo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
68 lines (55 loc) · 1.53 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
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
# coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.
"""
Deployment file to facilitate releases.
Note that this file is meant to be run from the root directory.
"""
import os
import json
import requests
import re
from invoke import task
from flamyngo import __version__ as ver
@task
def publish(ctx):
ctx.run("rm dist/*.*", warn=True)
ctx.run("python setup.py sdist bdist_wheel")
ctx.run("twine upload dist/*")
@task
def setver(ctx):
ctx.run(f"sed s/version=.*,/version=\\\"{ver}\\\",/ setup.py > newsetup")
ctx.run("mv newsetup setup.py")
@task
def merge_stable(ctx):
ctx.run("git add .")
ctx.run(f"git commit -a -m \"v{ver} release\"")
ctx.run("git push")
@task
def release_github(ctx):
with open("CHANGES.md") as f:
contents = f.read()
toks = re.split("##", contents)
desc = toks[1].strip()
toks = desc.split("\n")
desc = "\n".join(toks[1:]).strip()
payload = {
"tag_name": f"v{ver}",
"target_commitish": "master",
"name": f"v{ver}",
"body": desc,
"draft": False,
"prerelease": False
}
response = requests.post(
"https://api.github.com/repos/materialsvirtuallab/flamyngo/releases",
data=json.dumps(payload),
headers={"Authorization": "token " + os.environ["GITHUB_RELEASES_TOKEN"]})
print(response.text)
@task
def release(ctx, notest=False):
setver(ctx)
publish(ctx)
merge_stable(ctx)
# update_doc(ctx)
release_github(ctx)