From c7dd9de42ff93d94757a339fe3bf39dc42cd86f9 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 20 May 2017 14:37:40 -0700 Subject: [PATCH] Replace release automation with click (#3557) * Replace release automation with click * Fix * fix --- dev-requirements.txt | 2 +- docs/doing-a-release.rst | 2 +- tasks.py => release.py | 33 ++++++++++++++++++++++----------- 3 files changed, 24 insertions(+), 13 deletions(-) rename tasks.py => release.py (86%) diff --git a/dev-requirements.txt b/dev-requirements.txt index ab4584486..3213f1e5c 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,6 @@ +click clint coverage -invoke requests tox >= 2.4.1 twine diff --git a/docs/doing-a-release.rst b/docs/doing-a-release.rst index 2da2c80a8..7cf012bb0 100644 --- a/docs/doing-a-release.rst +++ b/docs/doing-a-release.rst @@ -42,7 +42,7 @@ The commit that merged the version number bump is now the official release commit for this release. You will need to have ``gpg`` installed and a ``gpg`` key in order to do a release. Once this has happened: -* Run ``invoke release {version}``. +* Run ``python release.py {version}``. The release should now be available on PyPI and a tag should be available in the repository. diff --git a/tasks.py b/release.py similarity index 86% rename from tasks.py rename to release.py index 2051093e8..7e2c1d81a 100644 --- a/tasks.py +++ b/release.py @@ -7,11 +7,12 @@ from __future__ import absolute_import, division, print_function import getpass import io import os +import subprocess import time -from clint.textui.progress import Bar as ProgressBar +import click -import invoke +from clint.textui.progress import Bar as ProgressBar import requests @@ -19,6 +20,11 @@ import requests JENKINS_URL = "https://jenkins.cryptography.io/job/cryptography-wheel-builder" +def run(*args, **kwargs): + kwargs.setdefault("stderr", subprocess.STDOUT) + subprocess.check_output(list(args), **kwargs) + + def wait_for_build_completed(session): # Wait 20 seconds before actually checking if the build is complete, to # ensure that it had time to really start. @@ -95,20 +101,21 @@ def download_artifacts(session): return paths -@invoke.task +@click.command() +@click.argument("version") def release(version): """ ``version`` should be a string like '0.4' or '1.0'. """ - invoke.run("git tag -s {0} -m '{0} release'".format(version)) - invoke.run("git push --tags") + run("git", "tag", "-s", version, "-m", "{0} release".format(version)) + run("git", "push", "--tags") - invoke.run("python setup.py sdist") - invoke.run("cd vectors/ && python setup.py sdist bdist_wheel") + run("python", "setup.py", "sdist") + run("python", "setup.py", "sdist", "bdist_wheel", cwd="vectors/") - invoke.run( - "twine upload -s dist/cryptography-{0}* " - "vectors/dist/cryptography_vectors-{0}*".format(version) + run( + "twine", "upload", "-s", "dist/cryptography-{0}*".format(version), + "vectors/dist/cryptography_vectors-{0}*".format(version), shell=True ) session = requests.Session() @@ -135,4 +142,8 @@ def release(version): response.raise_for_status() wait_for_build_completed(session) paths = download_artifacts(session) - invoke.run("twine upload {0}".format(" ".join(paths))) + run("twine", "upload", " ".join(paths)) + + +if __name__ == "__main__": + release()