diff options
author | Marco Pesenti Gritti <mpgritti@gmail.com> | 2008-10-20 01:42:37 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <mpgritti@gmail.com> | 2008-10-20 01:42:37 (GMT) |
commit | eff133a56e1cb8af4514b19e172d24033b835a36 (patch) | |
tree | a7eab72be415dacaa21f94b8f24cbe2df760dc9a /release |
Initial release script.
Diffstat (limited to 'release')
-rwxr-xr-x | release | 65 |
1 files changed, 65 insertions, 0 deletions
@@ -0,0 +1,65 @@ +#!/usr/bin/env python +# Copyright (C) 2008, Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import optparse +import os +import re + +base_dir = os.getcwd() + +class Release(object): + def next_version(self, current): + splitted = current.split('.') + new_minor = int(splitted[-1]) + 1 + splitted[-1] = str(new_minor) + + return '.'.join(splitted) + +class ActivityRelease(Release): + def bump_version(self, version): + pass + +class AutomakeRelease(Release): + def bump_version(self, version): + path = os.path.join(base_dir, 'configure.ac') + config = open(path).read() + + m = re.match('AC_INIT\(\[.*?\],\[(.*?)\]', config) + if m: + if version is None: + version = self.next_version(m.group(1)) + config = config[:m.start(1)] + version + config[m.end(1):] + + open(path, "w").write(config) + +def main(): + parser = optparse.OptionParser() + parser.add_option('-v', '--version', dest='version', + help='Release version') + (options, args) = parser.parse_args() + + if os.path.exists(os.path.join(base_dir, 'configure.ac')): + release = AutomakeRelease() + elif os.path.exists(os.path.join(base_dir, 'setup.py')): + release = ActivityRelease() + else: + print 'Unknow module type.' + + print 'Bump version number...' + release.bump_version(options.version) + +main() |