-
Notifications
You must be signed in to change notification settings - Fork 17
/
release.py
executable file
·38 lines (29 loc) · 1.33 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
#!/usr/bin/env python3
import io
from os.path import dirname, join
import extern
def get_version(relpath):
"""Read version info from a file without importing it"""
for line in io.open(join(dirname(__file__), relpath), encoding="cp437"):
if "__version__" in line:
if '"' in line:
return line.split('"')[1]
elif "'" in line:
return line.split("'")[1]
if __name__ == "__main__":
version = get_version('singlem/version.py')
print("version is {}".format(version))
yes_no = input(
"Did you run the non-CI tests first, to make sure everything is OK (y/n)? \n\npytest test/test_outside_ci.py\n\n"
)
if yes_no != "y":
raise Exception("Please run the non-CI tests first")
print("building docs")
extern.run("python3 build_docs.py")
print(
"Checking if repo is clean. If this fails it might be because the docs have changed from the previous command here?"
)
extern.run('if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then exit 1; fi')
extern.run('git tag v{}'.format(version))
print("Now run 'git push && git push --tags' and GitHub actions will build and upload to PyPI".format(version))
print('You have to run ./build.sh from the docker directory to build the docker image, once the tag is on GitHub')