Skip to content

Commit 3a7c978

Browse files
author
Eric Kolve
committed
adding tasks
1 parent 5839b32 commit 3a7c978

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tasks.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from invoke import task
2+
import subprocess
3+
import os
4+
import requests
5+
6+
7+
8+
@task
9+
def build_pip(context):
10+
import xml.etree.ElementTree as ET
11+
res = requests.get('https://test.pypi.org/rss/project/ekolve-testpython/releases.xml')
12+
res.raise_for_status()
13+
14+
git_tag_version = (
15+
subprocess.check_output("git describe --tags --exact-match", shell=True)
16+
.decode("ascii")
17+
.strip()
18+
)
19+
20+
root = ET.fromstring(res.content)
21+
latest_version = None
22+
23+
for title in root.findall('./channel/item/title'):
24+
latest_version = title.text
25+
break
26+
27+
current_maj, current_min, current_sub = latest_version.split('.')
28+
next_maj, next_min, next_sub = git_tag_version.split('.')
29+
30+
if (next_maj > current_maj) or \
31+
(next_maj >= current_maj and next_min > current_min) or \
32+
(next_maj >= current_maj and next_min >= current_min and next_sub > current_sub):
33+
subprocess.check_call("python setup.py sdist bdist_wheel --universal", shell=True)
34+
else:
35+
raise Exception("Invalid version: %s is not greater than latest version %s" % (git_tag_version, latest_version))
36+
37+
38+
39+
@task
40+
def deploy_pip(context):
41+
if 'TWINE_PASSWORD' not in os.environ:
42+
raise Exception("Twine token not specified in environment")
43+
subprocess.check_call("twine upload --repository testpypi -u __token__ dist/*", shell=True)

0 commit comments

Comments
 (0)