Added release script
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent ab6bac1 · Browse files · 4 files·+144 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+144 added−4 removed
- other:+144 added−4 removed
Provenance
- Commit
3d14654- Tree
bfc28c4- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
ab6bac1
4 files changed+144 added−4 removed
modified:flask/__init__.py+2 added
8 unmodified lines9 :copyright: (c) 2010 by Armin Ronacher.10 :license: BSD, see LICENSE for more details.11 """12 13+__version__ = '0.7'14+15 # utilities we import from Werkzeug and Jinja2 that are unused16 # in the module but are exported as public interface.17 from werkzeug import abort, redirect18 from jinja2 import Markup, escape20 unmodified linesadded:scripts/make-release.py+138 added
1+#!/usr/bin/env python2+# -*- coding: utf-8 -*-3+"""4+ make-release5+ ~~~~~~~~~~~~6+7+ Helper script that performs a release. Does pretty much everything8+ automatically for us.9+10+ :copyright: (c) 2011 by Armin Ronacher.11+ :license: BSD, see LICENSE for more details.12+"""13+import sys14+import os15+import re16+from datetime import datetime, date17+from subprocess import Popen, PIPE18+19+20+def parse_changelog():21+ with open('CHANGES') as f:22+ lineiter = iter(f)23+ for line in lineiter:24+ match = re.search('^Version\s+(.*)', line.strip())25+ if match is None:26+ continue27+ length = len(match.group(1))28+ version = match.group(1).strip()29+ if lineiter.next().count('-') != len(match.group(0)):30+ continue31+ while 1:32+ change_info = lineiter.next().strip()33+ if change_info:34+ break35+36+ match = re.match(r'^released on (\w+\s+\d+\w+\s+\d+)'37+ r'(?:, codename (.*))?(?i)', change_info)38+ if match is None:39+ continue40+41+ datestr, codename = match.groups()42+ return version, parse_date(datestr), codename43+44+45+def parse_date(string):46+ string = string.replace('th ', ' ').replace('nd ', ' ') \47+ .replace('rd ', ' ').replace('st ', ' ')48+ return datetime.strptime(string, '%B %d %Y')49+50+51+def set_filename_version(filename, version_number, pattern):52+ changed = []53+ def inject_version(match):54+ before, old, after = match.groups()55+ changed.append(True)56+ return before + version_number + after57+ with open(filename) as f:58+ contents = re.sub(r"^(\s*%s\s*=\s*')(.+?)(')(?sm)" % pattern,59+ inject_version, f.read())60+61+ if not changed:62+ fail('Could not find %s in %s', pattern, filename)63+64+ with open(filename, 'w') as f:65+ f.write(contents)66+67+68+def set_init_version(version):69+ info('Setting __init__.py version to %s', version)70+ set_filename_version('flask/__init__.py', version, '__version__')71+72+73+def set_setup_version(version):74+ info('Setting setup.py version to %s', version)75+ set_filename_version('setup.py', version, 'version')76+77+78+def build_and_upload():79+ Popen([sys.executable, 'setup.py', 'sdist', 'release']).wait()80+81+82+def fail(message, *args):83+ print >> sys.stderr, 'Error:', message % args84+ sys.exit(1)85+86+87+def info(message, *args):88+ print >> sys.stderr, message % args89+90+91+def get_git_tags():92+ return set(Popen(['git', 'tag'], stdout=PIPE).communicate()[0].splitlines())93+94+95+def git_is_clean():96+ return Popen(['git', 'diff', '--quiet']).wait() == 097+98+99+def make_git_commit(message, *args):100+ message = message % args101+ Popen(['git', 'commit', '-am', message]).wait()102+103+104+def make_git_tag(tag):105+ info('Tagging "%s"', tag)106+ Popen(['git', 'tag', tag]).wait()107+108+109+def main():110+ os.chdir(os.path.join(os.path.dirname(__file__), '..'))111+112+ rv = parse_changelog()113+ if rv is None:114+ fail('Could not parse changelog')115+116+ version, release_date, codename = rv117+118+ info('Releasing %s (codename %s, release date %s)',119+ version, codename, release_date.strftime('%d/%m/%Y'))120+ tags = get_git_tags()121+122+ if version in tags:123+ fail('Version "%s" is already tagged', version)124+ if release_date.date() != date.today():125+ fail('Release date is not today (%s != %s)')126+127+ if not git_is_clean():128+ fail('You have uncommitted changes in git')129+130+ set_init_version(version)131+ set_setup_version(version)132+ make_git_commit('Bump version number to %s', version)133+ make_git_tag(version)134+ build_and_upload()135+136+137+if __name__ == '__main__':138+ main()modified:CHANGES+1 added-1 removed
4 unmodified lines5 6 Version 0.77 -----------8 9-Release date to be announced, codename to be selected9+Released on June 27th 2011, codename Grappa10 11 - Added :meth:`~flask.Flask.make_default_options_response`12 which can be used by subclasses to alter the default13 behaviour for `OPTIONS` responses.208 unmodified linesmodified:Makefile+3 added-3 removed
6 unmodified lines7 8 audit:9 python setup.py audit10 11+release:12+ python scripts/make-release.py13+14 tox-test:15 PYTHONDONTWRITEBYTECODE= tox16 17 ext-test:18 python tests/flaskext_test.py --browse19 17-release:18- python setup.py release sdist upload19-20 clean-pyc:21 find . -name '*.pyc' -exec rm -f {} +22 find . -name '*.pyo' -exec rm -f {} +23 find . -name '*~' -exec rm -f {} +11 unmodified lines