-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.py
64 lines (48 loc) · 1.51 KB
/
release.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
import shutil
import subprocess
from pathlib import Path
import drf_versioning
import glob
version = drf_versioning.__version__
def cleanup():
paths = ["dist", "site", ".pytest_cache"]
paths += glob.glob("*.egg-info")
paths += glob.glob("*.pytest_cache")
for path in paths:
path = Path(__file__).parent / path
if path.exists():
shutil.rmtree(path)
def check(question: str):
response = input(question + "\n")
if response.lower() not in ["y", "yes"]:
raise Exception(f"Action required")
def shell(cmd: str):
subprocess.run(cmd, shell=True)
if __name__ == "__main__":
print(f"Releasing version {version}")
cleanup()
check(f"Did you create / update the Version changelog for version {version}?")
print("Running tests")
check("Did all the tests pass?")
print("Building package")
shell("python -m build")
shell("twine check dist/*")
print("PyPI test run")
shell("twine upload -r pypitest dist/*")
check(f"Does the testpypi output look OK?")
print("PyPI deploy")
shell("twine upload dist/*")
print("Building docs")
shell(f"mike deploy {version}")
shell(f"mike alias {version} latest --update-aliases")
try:
process = shell("mike serve")
except KeyboardInterrupt:
pass
check("Do the docs look OK?")
shell("mike list")
check("Does the list of docs versions look OK?")
print("Deploying docs")
shell(f"mike set-default latest --push")
cleanup()
print("Done!")