-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpre-deploy.py
executable file
·31 lines (26 loc) · 928 Bytes
/
pre-deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
import json
import requests
from configparser import ConfigParser
base_test_pypi_url = "https://test.pypi.org/pypi/naughty-string-validator/json"
def get_latest_nsv_version_from_pypi():
res = requests.get(base_test_pypi_url)
body = json.loads(res.text)
releases = body.get('releases', {})
latest_release = max([key for key in releases])
return latest_release
def get_current_version_to_deploy():
data_file = '.bumpversion.cfg'
config = ConfigParser()
config.read(data_file)
current_version = config['bumpversion']['current_version']
return current_version
def deploy():
deployed_version = get_latest_nsv_version_from_pypi()
current_version = get_current_version_to_deploy()
# return success code 0 when deployment is needed
if current_version > deployed_version:
return sys.exit(0)
return sys.exit(1)
if __name__ == "__main__":
deploy()