diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-02-13 19:36:58 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-02-14 11:11:05 +0200 |
commit | 2131ab187c0a482904a2d3a8a60942ce23f10348 (patch) | |
tree | 457ab08b45dbf4781ef78a7caf4edf20d779fda8 /bumper | |
parent | e40d9119c43e475951b1ce63cd9d67b44516cd89 (diff) | |
download | bumper-2131ab187c0a482904a2d3a8a60942ce23f10348.tar.gz |
Add preliminary initial scenario
Diffstat (limited to 'bumper')
-rwxr-xr-x | bumper | 63 |
1 files changed, 63 insertions, 0 deletions
@@ -0,0 +1,63 @@ +#!/usr/bin/env python2 +# Copyright 2016 Lars Wirzenius +# +# 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 3 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, see <http://www.gnu.org/licenses/>. +# +# =*= License: GPL-3+ =*= + + +import cliapp + + +class Bumper(cliapp.Application): + + def process_args(self, args): + print 'args:', repr(args) + version = args[0] + filename = args[1] + self.write_version_py(filename, version) + self.commit(filename) + self.make_release_tag(version) + + def commit(self, filename): + cliapp.runcmd(['git', 'commit', '-m', 'Version bump', filename]) + + def make_release_tag(self, version): + name = self.get_project_name() + tag_name = '{}-{}'.format(name, version) + msg = 'Release version {}'.format(version) + cliapp.runcmd(['git', 'tag', '-am', msg, tag_name]) + + def get_project_name(self): + output = cliapp.runcmd(['python', 'setup.py', '--name']) + return output.strip() + + def write_version_py(self, filename, version): + version_info = self.parse_version_info(version) + with open(filename, 'w') as f: + f.write('__version__ = "{}"\n'.format(version)) + f.write('__version_info__ = {!r}\n'.format(version_info)) + + def parse_version_info(self, version): + parts = version.split('.') + result = [] + for part in parts: + try: + result.append(int(part)) + except ValueError: + result.append(part) + return tuple(result) + + +Bumper().run() |