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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
#!/usr/bin/env python
#
# Performs a release of Review Board. This can only be run by the core
# developers with release permissions.
#
import os
import re
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
from rbtools import get_package_version, VERSION
PY_VERSIONS = ["2.4", "2.5", "2.6"]
LATEST_PY_VERSION = PY_VERSIONS[-1]
PACKAGE_NAME = 'RBTools'
RELEASES_URL = \
'reviewboard.org:/var/www/downloads.reviewboard.org/' \
'htdocs/releases/%s/%s.%s/' % (PACKAGE_NAME, VERSION[0], VERSION[1])
built_files = []
def execute(cmdline):
print ">>> %s" % cmdline
if os.system(cmdline) != 0:
print "!!! Error invoking command."
sys.exit(1)
def run_setup(target, pyver = LATEST_PY_VERSION):
execute("python%s ./setup.py release %s" % (pyver, target))
def build_targets():
for pyver in PY_VERSIONS:
run_setup("bdist_egg", pyver)
built_files.append("dist/%s-%s-py%s.egg" %
(PACKAGE_NAME, get_package_version(), pyver))
run_setup("sdist")
built_files.append("dist/%s-%s.tar.gz" %
(PACKAGE_NAME, get_package_version()))
def build_news():
def linkify_bugs(line):
return re.sub(r'(Bug #(\d+))',
r'<a href="http://www.reviewboard.org/bug/\2">\1</a>',
line)
content = ""
html_content = ""
saw_version = False
in_list = False
in_item = False
fp = open("NEWS", "r")
for line in fp.xreadlines():
line = line.rstrip()
if line.startswith("version "):
if saw_version:
# We're done.
break
saw_version = True
elif line.startswith("\t* "):
if in_item:
html_content += "</li>\n"
in_item = False
if in_list:
html_content += "</ul>\n"
html_content += "<p><b>%s</b></p>\n" % line[3:]
html_content += "<ul>\n"
in_list = True
elif line.startswith("\t\t* "):
if not in_list:
sys.stderr.write("*** Found a list item without a list!\n")
continue
if in_item:
html_content += "</li>\n"
html_content += " <li>%s" % linkify_bugs(line[4:])
in_item = True
elif line.startswith("\t\t "):
if not in_item:
sys.stderr.write("*** Found list item content without "
"a list item!\n")
continue
html_content += " " + linkify_bugs(line[4:])
content += line + "\n"
fp.close()
if in_item:
html_content += "</li>\n"
if in_list:
html_content += "</ul>\n"
content = content.rstrip()
filename = "dist/%s-%s.NEWS" % (PACKAGE_NAME, get_package_version())
built_files.append(filename)
fp = open(filename, "w")
fp.write(content)
fp.close()
filename = "dist/%s-%s.NEWS.html" % (PACKAGE_NAME, get_package_version())
fp = open(filename, "w")
fp.write(html_content)
fp.close()
def upload_files():
execute("scp %s %s" % (" ".join(built_files), RELEASES_URL))
def tag_release():
execute("git tag release-%s" % get_package_version())
def register_release():
run_setup("register")
def main():
if not os.path.exists("setup.py"):
sys.stderr.write("This must be run from the root of the "
"Djblets tree.\n")
sys.exit(1)
build_targets()
build_news()
upload_files()
tag_release()
register_release()
if __name__ == "__main__":
main()
|