459
by Aaron Bentley
Add script for automated releases |
1 |
#!/usr/bin/env python2.4
|
2 |
import os |
|
3 |
import re |
|
4 |
from subprocess import call |
|
5 |
import sys |
|
6 |
||
7 |
sys.path.insert(0, '..') |
|
8 |
sys.path.insert(0, os.path.dirname(os.path.realpath('/home/abentley/bin/bzr'))) |
|
9 |
import bzrtools |
|
10 |
print "bzrtools version: %s" % bzrtools.__version__ |
|
11 |
def minigrep(pattern, filename): |
|
12 |
setup = open(filename, 'rb') |
|
13 |
for line in setup: |
|
14 |
match = re.search(pattern, line) |
|
15 |
if match is not None: |
|
16 |
return match |
|
17 |
match = minigrep('version="([^"]*)"', 'setup.py') |
|
18 |
if match is None: |
|
19 |
print "No version line found" |
|
20 |
sys.exit(1) |
|
21 |
if match.group(1) != bzrtools.__version__: |
|
22 |
print "Mismatch between bzrtools version and setup.py version:\n %s %s"\ |
|
23 |
% (bzrtools.__version__, match.group(1)) |
|
24 |
sys.exit(1) |
|
25 |
||
26 |
print "setup.py version: %s" % match.group(1) |
|
27 |
newsmatch = minigrep('RELEASE: bzrtools %s' % (bzrtools.__version__), 'NEWS') |
|
28 |
if newsmatch is None: |
|
29 |
print "NEWS entry missing" |
|
30 |
sys.exit(1) |
|
31 |
else: |
|
32 |
print "NEWS entry found" |
|
33 |
final_name = '../bzrtools-%s.tar.gz' % bzrtools.__version__ |
|
34 |
if os.path.exists('../bzrtools.tar.gz'): |
|
35 |
print "Temp file exists already." |
|
36 |
sys.exit(1) |
|
37 |
if os.path.exists(final_name): |
|
38 |
print "Final file exists already." |
|
39 |
sys.exit(1) |
|
40 |
retcode = call(['bzr', 'export', '../bzrtools.tar.gz']) |
|
41 |
if retcode != 0: |
|
42 |
sys.exit(1) |
|
43 |
os.rename('../bzrtools.tar.gz', final_name) |
|
44 |
print 'Created %s' % final_name |
|
45 |
call(['gpg', '--detach-sign', final_name]) |
|
46 |
print 'Uploading...' |
|
47 |
call(['scp', final_name, final_name + '.sig', |
|
48 |
'panoramicfeedback.com:opensource/']) |
|
49 |
print "If you haven't committed, now would be a good time." |