summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tasks.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tasks.py b/tasks.py
index 583674e9..c7b35407 100644
--- a/tasks.py
+++ b/tasks.py
@@ -173,6 +173,22 @@ def clean_all(context):
pass
namespace_clean.add_task(clean_all, 'all')
+@invoke.task
+def tag(context, name='', message=''):
+ "Add a Git tag and push it to origin"
+ # If a tag was provided on the command-line, then add a Git tag and push it to origin
+ if name:
+ context.run('git tag -a {} -m {!r}'.format(name, message))
+ context.run('git push origin {}'.format(name))
+namespace.add_task(tag)
+
+@invoke.task()
+def validatetag(context):
+ "Check to make sure that a tag exists for the current HEAD"
+ # Validate that a Git tag exists for the current commit HEAD
+ context.run("git describe --exact-match --tags $(git log -n1 --pretty='%h')")
+namespace.add_task(validatetag)
+
@invoke.task(pre=[clean_all])
def sdist(context):
"Create a source distribution"
@@ -185,13 +201,13 @@ def wheel(context):
context.run('python setup.py bdist_wheel')
namespace.add_task(wheel)
-@invoke.task(pre=[sdist, wheel])
+@invoke.task(pre=[validatetag, sdist, wheel])
def pypi(context):
"Build and upload a distribution to pypi"
context.run('twine upload dist/*')
namespace.add_task(pypi)
-@invoke.task(pre=[sdist, wheel])
+@invoke.task(pre=[validatetag, sdist, wheel])
def pypi_test(context):
"Build and upload a distribution to https://test.pypi.org"
context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*')