diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2011-10-14 12:00:36 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2011-10-14 12:00:36 -0400 |
commit | 92a211d570706bb5ecebaeea04845ceec9c77ac3 (patch) | |
tree | 24f986c33726b425afb117e3a9b87aeaeeab0c3c | |
parent | 8372d395c718cf17a144eb6db314832eb86582e9 (diff) | |
download | external_python_setuptools-92a211d570706bb5ecebaeea04845ceec9c77ac3.tar.gz external_python_setuptools-92a211d570706bb5ecebaeea04845ceec9c77ac3.tar.bz2 external_python_setuptools-92a211d570706bb5ecebaeea04845ceec9c77ac3.zip |
Adding release.py, an attempt to fully automate the release process in a platform-friendly way. If this works, it should replace release.sh.
--HG--
branch : distribute
extra : rebase_source : b4297ff244fc6e2fa68f5891a226cd7840166e22
-rw-r--r-- | release.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/release.py b/release.py new file mode 100644 index 00000000..958d9373 --- /dev/null +++ b/release.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python + +""" +Script to fully automate the release process. Requires Python 2.6+ +with sphinx installed and the 'hg' command on the path. +""" + +from __future__ import print_function + +import subprocess +import shutil +import os +import sys + +VERSION='0.6.24' + +def get_next_version(): + digits = map(int, VERSION.split('.')) + digits[-1] += 1 + return '.'.join(map(str, digits)) + +def bump_versions(): + files_with_versions = ('docs/conf.py', 'setup.py', 'release.py', + 'release.sh', 'README.txt', 'distribute_setup.py') + list(map(bump_version, files_with_versions)) + +def bump_version(filename): + with open(filename, 'rb') as f: + lines = [line.replace(VERSION, get_next_version()) for line in f] + with open(filename, 'wb') as f: + f.writelines(lines) + +def do_release(): + res = raw_input('Have you read through the SCM changelog and ' + 'confirmed the changelog is current for releasing {VERSION}? ' + .format(**globals())) + if not res.lower.startswith('y'): + print("Please do that") + raise SystemExit(1) + + subprocess.check_call(['hg', 'tag', VERSION]) + + subprocess.check_call(['hg', 'update', VERSION]) + + build_docs() + shutil.rmtree('./dist') + subprocess.check_call([sys.executable, 'setup.py', + '-q', 'egg_info', '-RD', '-b', '""', 'sdist', 'register', + 'upload', 'upload_docs']) + upload_boostrap_script() + + # we just tagged the current version, bump for the next release. + bump_versions() + subprocess.check_call(['hg', 'ci', '-m', + 'Bumped to {VERSION} in preparation for next release.'.format(**globals())]) + + # push the changes + subprocess.check_call(['hg', 'push']) + +def build_docs(): + shutil.rmtree('docs/build') + subprocess.check_call([ + 'sphinx-build', + '-b', 'html', + 'build/html', + ], + cwd='docs') + +def upload_bootstrap_script(): + scp_command = 'pscp' if sys.platform.startswith('win') else 'scp' + try: + subprocess.check_call([scp_command, 'distribute_setup.py', + 'ziade.org:websites/python-distribute.org/']) + except: + print("Unable to upload bootstrap script. Ask Tarek to do it.") + +if __name__ == '__main__': + do_release() |