summaryrefslogtreecommitdiff
path: root/release
blob: e87c1ac9067a12faf91c1074ca5253a7f4dd93ac (plain)
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
#!/usr/bin/python

import os
import sys
import datetime
import shutil

def command(c):
    os.system(c)
    print c

def release_version(s):
    s = s[1:-1]
    if s.endswith('pre'):
        s = s[0:-3]
    p = s.split('.')
    return '0.%02d' % int(p[1])

def new_pre_version(s):
    s = s[1:-1]
    p = s.split('.')
    return '0.%02dpre' % (int(p[1]) + 1)

def rewrite_wscript(version_maker):
    f = open('wscript', 'rw')
    o = open('wscript.tmp', 'w')
    while 1:
        l = f.readline()
        if l == '':
            break

        s = l.split()
        if len(s) == 3 and s[0] == "VERSION":
            v = version_maker(s[2])
            print "REWRITE %s -> %s" % (s[2], v)
            print >>o,"VERSION = '%s'" % v
        else:
            print >>o,l,
    f.close()
    o.close()

    os.rename('wscript.tmp', 'wscript')
    return v

def append_to_changelog(version):
    f = open('ChangeLog', 'r')
    c = f.read()
    f.close()

    f = open('ChangeLog', 'w')
    now = datetime.datetime.now()
    f.write('%d-%02d-%02d  Carl Hetherington  <cth@carlh.net>\n\n\t* Version %s released.\n\n' % (now.year, now.month, now.day, version))
    f.write(c)

release_version_string = rewrite_wscript(release_version)
#append_to_changelog(release_version_string)

command("git diff")
if raw_input() != "y":
    command("git reset --hard")
    print 'Aborted'
    sys.exit(1)

command("git commit -a -m \"Bump version\"")
print "git cleaning..."
command("git clean -n")
if raw_input() != "y":
    print 'Aborted'
    sys.exit(1)
command("git clean")
command("git tag -m \"v%s\" v%s" % (release_version_string, release_version_string))
command("./waf clean")
command("./waf")
command("./waf configure")
command("./waf dist")

rewrite_wscript(new_pre_version)

command("git diff")
if raw_input() != "y":
    command("git reset --hard")
    print 'Aborted'
    sys.exit(1)

command("git commit -a -m \"Bump version\"")