forked from etetoolkit/ete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.py
executable file
·136 lines (107 loc) · 4.48 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import re
import commands
import os
import sys
import readline
from optparse import OptionParser
parser = OptionParser()
parser.add_option("--notest", dest="notest", action='store_true')
parser.add_option("--nodoc", dest="nodoc", action='store_true')
parser.add_option("--simulate", dest="simulate", action='store_true')
parser.add_option("--verbose", dest="verbose", action='store_true')
parser.add_option("--doconly", dest="doconly", action='store_true')
(options, args) = parser.parse_args()
def _ex(cmd, interrupt=True):
if options.verbose or options.simulate:
print "***", cmd
if not options.simulate:
s = os.system(cmd)
if s != 0 and interrupt:
sys.exit(s)
else:
return s
else:
return 0
def ask(string, valid_values, default=-1, case_sensitive=False):
""" Asks for a keyborad answer """
v = None
if not case_sensitive:
valid_values = [value.lower() for value in valid_values]
while v not in valid_values:
readline.set_startup_hook(lambda: readline.insert_text(default))
try:
v = raw_input("%s [%s] " % (string, ', '.join(valid_values))).strip()
if v == '' and default>=0:
v = valid_values[default]
if not case_sensitive:
v = v.lower()
finally:
readline.set_startup_hook()
return v
def ask_path(string, default_path):
v = None
while v is None:
v = raw_input("%s [%s] " % (string, default_path)).strip()
if v == '':
v = default_path
if not os.path.exists(v):
print >>sys.stderr, v, "does not exist."
v = None
return v
SERVER="huerta@etetoolkit.embl.de"
SERVER_RELEASES_PATH = "/var/www/etetoolkit/static/releases/ete3"
TEMP_PATH = "/tmp"
CURRENT_VERSION = open('VERSION').readline().strip()
a, b, c, tag, ncom, hcom = re.search("(\d+)\.(\d+)\.(\d+)(-?\w+\d+)?-?(\d+)?-?(\w+)?", CURRENT_VERSION).groups()
a, b, c = map(int, (a, b, c))
SERIES_VERSION = "%s.%s" %(a, b)
print '===================================================='
print 'CURRENT VERSION:', a, b, c, tag, ncom, hcom
print '===================================================='
# test examples
raw_input('continue?')
if not options.doconly:
# commit changes in VERSION
if tag:
tag1, tag2 = re.search('(.+?)(\d+)', tag).groups()
tag2 = int(tag2)
NEW_VERSION = "%s.%s.%s%s%s" %(a, b, c, tag1, tag2+1)
else:
NEW_VERSION = "%s.%s.%s" %(a, b, c+1)
if ask('Increase version to "%s" ?' %NEW_VERSION, ['y', 'n']) == 'n':
NEW_VERSION = raw_input('new version string:').strip()
if ask('Write "%s" and commit changes?' %NEW_VERSION, ['y', 'n']) == 'y':
open('VERSION', 'w').write(NEW_VERSION)
_ex('git commit -a -m "release %s " && git tag -f %s' %(NEW_VERSION, NEW_VERSION))
else:
NEW_VERSION = CURRENT_VERSION
# clean files from previous releases
_ex('rm release/ -rf && git clone . release/')
# build docs
_ex('cd release/sdoc/ && make html && make latex')
_ex('cd release/sdoc/_build/latex && make all-pdf')
# Generates HTML doc (it includes a link to the PDF doc, so it
# must be executed after PDF commands)
_ex('cp -a release/sdoc/_build/html/ release/doc/')
_ex('cp -a release/sdoc/_build/latex/*.pdf release/doc/')
# Build dist
_ex('cd release/ && python setup.py sdist')
# test distribution
if not options.notest:
_ex('cd release/dist/ && tar xf ete3-%s.tar.gz && cd ete3-%s/test/ && python test_all.py && python test_treeview.py' %(NEW_VERSION, NEW_VERSION))
if ask('Upload to TEST pypi?', ['y', 'n']) == 'y':
_ex('cd release/ && python setup.py sdist upload -r https://testpypi.python.org/pypi')
if ask('Upload to pypi?', ['y', 'n']) == 'y':
_ex('cd release/ && python setup.py sdist upload -r https://pypi.python.org/pypi')
if options.doconly:
SDOC_PATH = '.'
# build docs
_ex('cd sdoc/ && make html && make latex')
_ex('cd sdoc/_build/latex && make all-pdf')
_ex('cp -a sdoc/_build/latex/*.pdf sdoc/_build/html/_downloads/')
else:
SDOC_PATH = 'release/'
if ask('Upload docs?', ['y', 'n']) == 'y':
_ex("cd %s; python setup.py upload_sphinx --upload-dir sdoc/_build/html/ -r https://pypi.python.org/pypi --show-response" %SDOC_PATH)
#_ex('deactivate; release/dist/ && tar xf ete2-%s.tar.gz && cd ete2-%s/test/ && python test_all.py && python test_treeview.py' %(NEW_VERSION, NEW_VERSION))
sys.exit(0)