X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=release;h=19b244037ae022df3e51ea0e3ab5b067a454340b;hb=840952af7e3f9456d5eb1cf4994c3160ebf4a374;hp=ad5bdbbf1d1bbe68bb03dbc008a5f827681e20ec;hpb=60990830b23f295d218b6ae549654e5c67a7bdff;p=dcpomatic.git diff --git a/release b/release index ad5bdbbf1..19b244037 100755 --- a/release +++ b/release @@ -4,82 +4,60 @@ import os import sys import datetime import shutil +import version +import argparse -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 +parser = argparse.ArgumentParser(description = "Build and tag a release.") +parser.add_argument('-f', '--full', dest='full', action='store_const', const=True, help="full release", default=False) +parser.add_argument('-b', '--beta', dest='beta', action='store_const', const=True, help="beta release", default=False) +parser.add_argument('-d', '--debug', dest='debug', action='store_const', const=True, help="show commands but don't do anything", default=False) +args = parser.parse_args() - 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 +if not args.full and not args.beta: + print "%s: must specify --full or --beta" % sys.argv[0] + sys.exit(1) -def append_to_changelog(version): - f = open('ChangeLog', 'r') - c = f.read() - f.close() +def command(c): + if not args.debug: + os.system(c) + print c - f = open('ChangeLog', 'w') - now = datetime.datetime.now() - f.write('%d-%02d-%02d Carl Hetherington \n\n\t* Version %s released.\n\n' % (now.year, now.month, now.day, version)) - f.write(c) +def check_diff_with_user(): + print "Planning to commit... ok? [y/n]" + command("git diff") + if (raw_input() != "y"): + command("git reset --hard") + print 'Aborted' + sys.exit(1) -command("git checkout master") +if not args.debug and os.popen('git status -s').read() != '': + print '%s: uncommitted changes exist.' % sys.argv[0] + sys.exit(1) -release_version_string = rewrite_wscript(release_version) -append_to_changelog(release_version_string) +m = version.Version.to_release +if args.beta: + m = version.Version.bump_beta -command("git diff") -if (raw_input() != "y"): - command("git reset --hard") - print 'Aborted' - sys.exit(1) +new_version = version.rewrite_wscript(m) +version.append_to_changelog(new_version) -command("git commit -a -m \"Bump version\"") -command("git tag -m \"v%s\" v%s" % (release_version_string, release_version_string)) command("./waf clean") -command("./waf") command("./waf configure") +command("./waf") command("./waf dist") command("./builds/windows-32") -shutil.copy(os.path.join('build', 'windows', 'DVD-o-matic %s 32-bit Installer.exe' % release_version_string), '.') +shutil.copy(os.path.join('build', 'windows', 'DVD-o-matic %s 32-bit Installer.exe' % new_version), '.') command("./builds/windows-64") -shutil.copy(os.path.join('build', 'windows', 'DVD-o-matic %s 64-bit Installer.exe' % release_version_string), '.') +shutil.copy(os.path.join('build', 'windows', 'DVD-o-matic %s 64-bit Installer.exe' % new_version), '.') -rewrite_wscript(new_pre_version) - -command("git diff") -if (raw_input() != "y"): - command("git reset --hard") - print 'Aborted' - sys.exit(1) +check_diff_with_user() command("git commit -a -m \"Bump version\"") +command("git tag -m \"v%s\" v%s" % (new_version, new_version)) + +if args.release: + version.rewrite_wscript(version.Version.bump_and_to_pre) + check_diff_with_user() + command("git commit -a -m \"Bump version\"") + +command("cp DVD-o-matic*.exe dvdomatic-*.tar.bz2 /home/carl/public_html/carlh.net/software/dvdomatic")