-
Notifications
You must be signed in to change notification settings - Fork 35
/
make-release
executable file
·60 lines (47 loc) · 1.48 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
#! /usr/bin/env python
import os
import subprocess
import sys
def system(cmd, dry_run=False):
print("====> Running", cmd)
if dry_run:
return
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True, encoding="utf-8")
nl = True
while True:
char = popen.stdout.read(1)
if not char:
break
if nl:
sys.stdout.write(" ")
sys.stdout.write(char)
sys.stdout.flush()
nl = char == "\n"
st = popen.wait()
if st != 0:
sys.exit("Error: command %r failed" % cmd)
print()
def main():
dry_run = "dry" in os.environ
st, tags = subprocess.getstatusoutput("git tag")
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
print("building version", version)
st, descr = subprocess.getstatusoutput("git describe --all --dirty")
assert st == 0
dirty = "-dirty" in descr
if dirty:
print("working directory is dirty")
if not dirty:
system("git tag %s" % version)
system("%s setup.py sdist" % sys.executable)
system("%s setup.py register" % sys.executable, dry_run)
system("%s setup.py sdist upload" % sys.executable, dry_run)
else:
print("WARNING: build was dirty. did not upload or tag a release")
sys.exit(1)
if __name__ == "__main__":
main()