-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtasks.py
75 lines (60 loc) · 1.73 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
69
70
71
72
73
74
75
# coding: utf-8
# Copyright (c) Pymatgen Development Team.
# Distributed under the terms of the MIT License.
import os
import webbrowser
import requests
import json
from invoke import task
from monty.os import cd
from figrecipes import __version__
"""
Deployment file to facilitate releases.
"""
__author__ = "Shyue Ping Ong, Anubhav Jain"
__email__ = "[email protected]"
__date__ = "Sep 1, 2014"
@task
def make_doc(ctx):
with cd("docs_rst"):
ctx.run("sphinx-apidoc -o . -f ../figrecipes")
ctx.run("make html")
ctx.run("cp _static/* ../docs/html/_static")
with cd("docs"):
ctx.run("cp -r html/* .")
ctx.run("rm -r html")
ctx.run("rm -r doctrees")
# Avoid the use of jekyll so that _dir works as intended.
ctx.run("touch .nojekyll")
@task
def update_doc(ctx):
make_doc(ctx)
with cd("docs"):
ctx.run("git add .")
ctx.run("git commit -a -m \"Update to v{}\"".format(__version__))
ctx.run("git push")
@task
def open_doc(ctx):
pth = os.path.abspath("docs/index.html")
webbrowser.open("file://" + pth)
@task
def release(ctx):
payload = {
"tag_name": "v" + __version__,
"target_commitish": "main",
"name": "v" + __version__,
"body": "",
"draft": False,
"prerelease": False
}
response = requests.post(
"https://api.github.com/repos/hackingmaterials/figrecipes/releases",
data=json.dumps(payload),
headers={
"Authorization": "token " + os.environ["GITHUB_RELEASES_TOKEN"]})
print(response.text)
@task
def publish(ctx):
ctx.run("rm -r dist build", warn=True)
ctx.run("python3 setup.py sdist bdist_wheel")
ctx.run("twine upload dist/* --verbose")