Skip to content
Myr

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

4 files+144 added−4 removed

modified:flask/__init__.py+2 added
8 unmodified lines
9 :copyright: (c) 2010 by Armin Ronacher.10 :license: BSD, see LICENSE for more details.11"""1213__version__ = '0.7'1415# utilities we import from Werkzeug and Jinja2 that are unused16# in the module but are exported as public interface.17from werkzeug import abort, redirect18from jinja2 import Markup, escape
20 unmodified lines
added:scripts/make-release.py+138 added
1#!/usr/bin/env python2# -*- coding: utf-8 -*-3"""4 make-release5 ~~~~~~~~~~~~67 Helper script that performs a release. Does pretty much everything8 automatically for us.910 :copyright: (c) 2011 by Armin Ronacher.11 :license: BSD, see LICENSE for more details.12"""13import sys14import os15import re16from datetime import datetime, date17from subprocess import Popen, PIPE181920def 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 break3536 match = re.match(r'^released on (\w+\s+\d+\w+\s+\d+)'37 r'(?:, codename (.*))?(?i)', change_info)38 if match is None:39 continue4041 datestr, codename = match.groups()42 return version, parse_date(datestr), codename434445def parse_date(string):46 string = string.replace('th ', ' ').replace('nd ', ' ') \47 .replace('rd ', ' ').replace('st ', ' ')48 return datetime.strptime(string, '%B %d %Y')495051def 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())6061 if not changed:62 fail('Could not find %s in %s', pattern, filename)6364 with open(filename, 'w') as f:65 f.write(contents)666768def set_init_version(version):69 info('Setting __init__.py version to %s', version)70 set_filename_version('flask/__init__.py', version, '__version__')717273def set_setup_version(version):74 info('Setting setup.py version to %s', version)75 set_filename_version('setup.py', version, 'version')767778def build_and_upload():79 Popen([sys.executable, 'setup.py', 'sdist', 'release']).wait()808182def fail(message, *args):83 print >> sys.stderr, 'Error:', message % args84 sys.exit(1)858687def info(message, *args):88 print >> sys.stderr, message % args899091def get_git_tags():92 return set(Popen(['git', 'tag'], stdout=PIPE).communicate()[0].splitlines())939495def git_is_clean():96 return Popen(['git', 'diff', '--quiet']).wait() == 0979899def make_git_commit(message, *args):100 message = message % args101 Popen(['git', 'commit', '-am', message]).wait()102103104def make_git_tag(tag):105 info('Tagging "%s"', tag)106 Popen(['git', 'tag', tag]).wait()107108109def main():110 os.chdir(os.path.join(os.path.dirname(__file__), '..'))111112 rv = parse_changelog()113 if rv is None:114 fail('Could not parse changelog')115116 version, release_date, codename = rv117118 info('Releasing %s (codename %s, release date %s)',119 version, codename, release_date.strftime('%d/%m/%Y'))120 tags = get_git_tags()121122 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)')126127 if not git_is_clean():128 fail('You have uncommitted changes in git')129130 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()135136137if __name__ == '__main__':138 main()
modified:CHANGES+1 added-1 removed
4 unmodified lines
56Version 0.77-----------89Release date to be announced, codename to be selected9Released on June 27th 2011, codename Grappa1011- 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 lines
modified:Makefile+3 added-3 removed
6 unmodified lines
78audit:9 python setup.py audit1011release:12 python scripts/make-release.py1314tox-test:15 PYTHONDONTWRITEBYTECODE= tox1617ext-test:18 python tests/flaskext_test.py --browse1917release:18 python setup.py release sdist upload1920clean-pyc:21 find . -name '*.pyc' -exec rm -f {} +22 find . -name '*.pyo' -exec rm -f {} +23 find . -name '*~' -exec rm -f {} +
11 unmodified lines