2020-11-21 19:03:50 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
from requests import get
|
|
|
|
from sys import argv, exit
|
|
|
|
|
2021-04-02 16:57:13 +00:00
|
|
|
if not len(argv) == 3:
|
|
|
|
print('Usage: check_github_for_new_release <repo> <version>')
|
|
|
|
exit(3)
|
2020-11-21 19:03:50 +00:00
|
|
|
|
|
|
|
repo = argv[1]
|
|
|
|
current_version = argv[2]
|
|
|
|
|
|
|
|
try:
|
|
|
|
r = get('https://api.github.com/repos/{}/releases/latest'.format(repo), headers={'Accept': 'application/json'}).json()
|
|
|
|
except Exception as e:
|
|
|
|
print(repr(e))
|
|
|
|
exit(3)
|
|
|
|
|
2021-01-29 17:04:35 +00:00
|
|
|
newest_release = r['tag_name']
|
2020-11-21 19:03:50 +00:00
|
|
|
|
|
|
|
if newest_release != current_version:
|
|
|
|
print('There is a newer version available: {} (currently installed: {})'.format(newest_release, current_version))
|
|
|
|
|
|
|
|
if r['prerelease'] or r['draft']:
|
|
|
|
print('Please note this is only a prerelease/draft.')
|
|
|
|
|
|
|
|
# Don't alert people for prereleases.
|
|
|
|
exit(0)
|
|
|
|
else:
|
|
|
|
exit(2)
|
|
|
|
else:
|
|
|
|
print('Currently installed version matches newest release on github')
|
|
|
|
exit(0)
|