-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-release
executable file
·66 lines (51 loc) · 1.76 KB
/
make-release
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
#! /usr/bin/env python
from builtins import str
import subprocess
import sys
def get_status_output(*args, **kwargs):
p = subprocess.Popen(*args, **kwargs)
stdout, stderr = p.communicate()
return p.returncode, stdout, stderr
def system(cmd):
print("====> Running", cmd)
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, bufsize=1
)
for line in iter(p.stdout.readline, b""):
print(line)
st = p.wait()
if st != 0:
sys.exit("Error: command %r failed" % cmd)
print()
def main():
st, tags, _ = get_status_output(
"git tag", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True
)
assert st == 0, "failed to get tags"
tags = set(tags.split())
import setup
version = setup.get_version()
assert version not in tags, "already have tagged %s" % version
st, description, _ = get_status_output(
"git describe --all --dirty", stdout=subprocess.PIPE, shell=True
)
assert st == 0
dirty = "-dirty" in str(description)
if dirty:
print("working directory is dirty")
# st, tag = commands.getstatusoutput("git describe --tags --exact-match --dirty")
# tag = tag.strip()
# assert st == 0, "revision not tagged"
# import setup
# assert setup.get_version() == tag, "version mismatch: %s != %s" % (setup.get_version(), tag)
system("tox")
system("%s setup.py -q sdist" % sys.executable)
if not dirty:
system("%s setup.py register" % sys.executable)
system("%s setup.py -q sdist upload" % sys.executable)
system("git tag %s" % version)
else:
print("WARNING: build was dirty. did not upload or tag a release")
sys.exit(1)
if __name__ == "__main__":
main()