Replace release automation with click (#3557)

* Replace release automation with click

* Fix

* fix
diff --git a/dev-requirements.txt b/dev-requirements.txt
index ab45844..3213f1e 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 2da2c80..7cf012b 100644
--- a/docs/doing-a-release.rst
+++ b/docs/doing-a-release.rst
@@ -42,7 +42,7 @@
 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 2051093..7e2c1d8 100644
--- a/tasks.py
+++ b/release.py
@@ -7,11 +7,12 @@
 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 @@
 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 @@
     return paths
 
 
[email protected]
[email protected]()
[email protected]("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 @@
     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()