Skip to content

Commit 5ffaa3b

Browse files
author
Eric Kolve
committed
Merge branch 'master' of github.com:ekolve/testpython
2 parents 548f72b + 59706b6 commit 5ffaa3b

File tree

6 files changed

+72
-20
lines changed

6 files changed

+72
-20
lines changed

.travis.yml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
language: python
22
python:
3-
- '3.6'
3+
- '3.6'
44
install:
5-
- pip install requests
5+
- pip install requests invoke
66
cache: pip
77
script:
88
- true
9-
- env
10-
- git describe --tags --exact-match
11-
- git branch --format='%(refname:short)' --contains tags/$TRAVIS_TAG
129
git:
13-
depth: 3
10+
depth: 3
1411
deploy:
15-
provider: pypi
16-
username: __token__
17-
password:
18-
secure: m9SRup4q7R4plc1fuKUQE9y/M+vWeTbu/pYaizwRTN5HjhEXcnyg63gAkr/EO4T2VzKCobOsDJaySFmFfWYWkfktWLaw47dhtrbwrrPFeaCjg+wqF9y3jN5wvVlUwDPoaBJtFi3KL28aFg+RY+iO/bXUFgURRVUbnhK/vf39THcuSeo5Fys+jJKfWBIjxB6vyUR124WNkmFpLGgiDqxQXv1Mk+xPMSsry2iawTpZjyxeokpzA1rO5BX+orcMEs5Vm4x2eLVHtTtoqjY0UEvbclH/kA4u0XCT8FjdP+Kmv/qAP+hJALQk/IBSa5Id2VcGU5at65BvOpssWGXp60UPSOvLWLfoZIXBOPBOif3gJIbhfQGgoA7z+7dEChOx4ZlybDMguRWm4hupHZnkcZqftCmyV6lKTBdT8TGSuG+B1r6kmgLdg8yShvcnU3OaIgSpAQTN4LNJ5r+Ll4vdYCgbUy/YUOGsasxODJiPbxK+mOuDKtuVU6CV22TPVNKq+sdUWOq7ZbhwGVKneEJHTwnHvo+nWt9zsC8QGJXOuzBzhnFCdGcgH6Q4KbwpYqUMlB2/s79g6H3auVV6jiubl49LhxjUdHsp40GV+Nlt9ThIN2XHsPcicRMKDzYc+UjvY9u7hk2MMcvbwg7hfoYVaEy9sPb25vw7r31xS5u4IBBhWw4=
19-
server: https://test.pypi.org/legacy/
20-
edge: true
21-
distributions: sdist bdist_wheel --universal
22-
on:
23-
tags: true
24-
condition: $(git describe --tags --exact-match) && $TRAVIS_TAG =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ && $(git branch --format='%(refname:short)' --contains tags/$TRAVIS_TAG) = 'master'
25-
12+
provider: script
13+
script: bash build.sh
14+
on:
15+
tags: true
16+
condition: $TRAVIS_TAG =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$
2617
env:
27-
global:
28-
secure: m9SRup4q7R4plc1fuKUQE9y/M+vWeTbu/pYaizwRTN5HjhEXcnyg63gAkr/EO4T2VzKCobOsDJaySFmFfWYWkfktWLaw47dhtrbwrrPFeaCjg+wqF9y3jN5wvVlUwDPoaBJtFi3KL28aFg+RY+iO/bXUFgURRVUbnhK/vf39THcuSeo5Fys+jJKfWBIjxB6vyUR124WNkmFpLGgiDqxQXv1Mk+xPMSsry2iawTpZjyxeokpzA1rO5BX+orcMEs5Vm4x2eLVHtTtoqjY0UEvbclH/kA4u0XCT8FjdP+Kmv/qAP+hJALQk/IBSa5Id2VcGU5at65BvOpssWGXp60UPSOvLWLfoZIXBOPBOif3gJIbhfQGgoA7z+7dEChOx4ZlybDMguRWm4hupHZnkcZqftCmyV6lKTBdT8TGSuG+B1r6kmgLdg8yShvcnU3OaIgSpAQTN4LNJ5r+Ll4vdYCgbUy/YUOGsasxODJiPbxK+mOuDKtuVU6CV22TPVNKq+sdUWOq7ZbhwGVKneEJHTwnHvo+nWt9zsC8QGJXOuzBzhnFCdGcgH6Q4KbwpYqUMlB2/s79g6H3auVV6jiubl49LhxjUdHsp40GV+Nlt9ThIN2XHsPcicRMKDzYc+UjvY9u7hk2MMcvbwg7hfoYVaEy9sPb25vw7r31xS5u4IBBhWw4=
18+
global:
19+
secure: VyGJAszOT/AWo2RZe7Yt3JlORQSXzMly4YR+C2Xl96W0TkhjpQcra0i38GXaudFWyu2dAK5LGdwzj3Epdux9/3g88vJd6Bit27F1aTbLFWqCSDJ4clsD5KE1HQO9807tdtxf6Z1BbmvtC9IfyCCXTMr9AXtyIdkHIKYuqSRbS6mA7ZgnN7DUgq3/Q14jkiZ2KGdhtYpOnaLPnt/8BfbsrxvXNRgBBrX4kDeF4R0mu9ZYQ7CT36rBFUTht1V82/8726OUc7YYH/Q3884ty0shJ9mz0sF5Smp9zzypjdB1aDFD5NNTKvdJ4puiDeUdHKtqS+xdbe8YaIqyfUXIzdywBcwT4I7hg2n21Etud2mnDA2K8bW/C22ur6dQiaYD0UeL93sKMW4tBN+M3QEwjpiNS34+kSAXXATkFfyz0UXlKzJlWvvvJ/68aumBVXIUnWjieIurjTjOIaJs6DyACDF/7CnZ5lGk8I6wSKWVV3KeQ3JDnM+i7SMNS3dkXpN2x7YwJk2udcfvQe1jGqJ1U3jHmaVlc4fBiRYG8Gp/rorO3Apsex3dz5tiSvF2gCY7Y6KiXoCk1oYT6QzEHGRT/0BUxW4PVEL6COzYayRubQsqdawc8nemgR+p1ydW0lUe3hR6xfXmpDqc3pcGjs8XMwvS9qXYqNpqIY7YNlgjzi/HOtI=
20+

build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
pip3 install -e .
3+
pip3 install twine wheel invoke requests
4+
5+
if [[ $(git rev-parse --is-shallow-repository) == 'true' ]]; then
6+
git fetch --unshallow
7+
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
8+
git fetch origin
9+
fi;
10+
11+
invoke build-pip
12+
invoke deploy-pip
13+
twine upload --repository testpypi -u __token__ dist/*

build/lib/test/__init__.py

Whitespace-only changes.

build/lib/test/test_ocr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import mypackage
2+
3+
def test_thing():
4+
mypackage.mything(10)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
git_tag_version = (
7-
subprocess.check_output("git describe --tags", shell=True)
7+
subprocess.check_output("git describe --tags --exact-match", shell=True)
88
.decode("ascii")
99
.strip()
1010
)

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 = list(map(int, latest_version.split('.')))
28+
next_maj, next_min, next_sub = list(map(int, 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+
@task
39+
def deploy_pip(context):
40+
if 'TWINE_PASSWORD' not in os.environ:
41+
raise Exception("Twine token not specified in environment")
42+
subprocess.check_call("twine upload --repository testpypi -u __token__ dist/*", shell=True)
43+

0 commit comments

Comments
 (0)