Bump libdcp version.
[dcpomatic.git] / release
1 #!/usr/bin/python
2
3 import os
4 import sys
5 import datetime
6 import shutil
7 import version
8 import argparse
9
10 parser = argparse.ArgumentParser(description = "Build and tag a release.")
11 parser.add_argument('-f', '--full', dest='full', action='store_const', const=True, help="full release", default=False)
12 parser.add_argument('-b', '--beta', dest='beta', action='store_const', const=True, help="beta release", default=False)
13 parser.add_argument('-d', '--debug', dest='debug', action='store_const', const=True, help="show commands but don't do anything", default=False)
14 args = parser.parse_args()
15
16 if not args.full and not args.beta:
17     print "%s: must specify --full or --beta" % sys.argv[0]
18     sys.exit(1)
19
20 def command(c):
21     if not args.debug:
22         os.system(c)
23     print c
24
25 def check_diff_with_user():
26     print "Planning to commit... ok? [y/n]"
27     command("git diff")
28     if (raw_input() != "y"):
29         command("git reset --hard")
30         print 'Aborted'
31         sys.exit(1)
32
33 if not args.debug and os.popen('git status -s').read() != '':
34     print '%s: uncommitted changes exist.' % sys.argv[0]
35     sys.exit(1)
36
37 m = version.Version.to_release
38 if args.beta:
39     m = version.Version.bump_beta
40
41 new_version = version.rewrite_wscript(m)
42 version.append_to_changelog(new_version)
43
44 command("./waf clean")
45 command("./waf configure")
46 command("./waf")
47 command("./waf dist")
48 command("./builds/windows-32")
49 shutil.copy(os.path.join('build', 'windows', 'DVD-o-matic %s 32-bit Installer.exe' % new_version), '.')
50 command("./builds/windows-64")
51 shutil.copy(os.path.join('build', 'windows', 'DVD-o-matic %s 64-bit Installer.exe' % new_version), '.')
52
53 check_diff_with_user()
54
55 command("git commit -a -m \"Bump version\"")
56 command("git tag -m \"v%s\" v%s" % (new_version, new_version))
57
58 if args.release:
59     version.rewrite_wscript(version.Version.bump_and_to_pre)
60     check_diff_with_user()
61     command("git commit -a -m \"Bump version\"")
62
63 command("cp DVD-o-matic*.exe dvdomatic-*.tar.bz2 /home/carl/public_html/carlh.net/software/dvdomatic")