From 3ab8107adfbdc09cf509f72d96218207a7b03dcd Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 7 May 2014 20:04:20 -0700 Subject: [PATCH] Release script: larger `prep` command --- extra/release.py | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/extra/release.py b/extra/release.py index c7221f8df..59322292f 100644 --- a/extra/release.py +++ b/extra/release.py @@ -63,9 +63,7 @@ VERSION_LOCS = [ ] -@release.command() -@click.argument('version') -def bump(version): +def bump_version(version): """Update the version number in setup.py, docs config, changelog, and root module. """ @@ -125,11 +123,11 @@ def bump(version): @release.command() -def build(): - """Use `setup.py` to build a source tarball. +@click.argument('version') +def bump(version): + """Bump the version number. """ - with chdir(BASE): - subprocess.check_call(['python2', 'setup.py', 'sdist']) + bump_version(version) def get_latest_changelog(): @@ -247,5 +245,36 @@ def datestamp(): f.write(line) +@release.command() +def prep(): + """Run all steps to prepare a release. + + - Tag the commit. + - Build the sdist package. + - Generate the Markdown changelog to ``changelog.md``. + - Bump the version number to the next version. + """ + cur_version = get_version() + + # Tag. + subprocess.check_output(['git', 'tag', 'v{}'].format(cur_version)) + + # Build. + with chdir(BASE): + subprocess.check_call(['python2', 'setup.py', 'sdist']) + + # Generate Markdown changelog. + cl = changelog_as_markdown() + with open(os.path.join(BASE, 'changelog.md'), 'w') as f: + f.write(cl) + + # Version number bump. + # FIXME It should be possible to specify this as an argument. + version_parts = [int(n) for n in cur_version.split('.')] + version_parts[-1] += 1 + next_version = '.'.join(version_parts) + bump_version(next_version) + + if __name__ == '__main__': release()