Last active
July 23, 2018 04:55
-
-
Save l50/db44b128cd599a605bc30e200cdebc26 to your computer and use it in GitHub Desktop.
Python version of https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import requests | |
def parse_arg(): | |
parser = argparse.ArgumentParser(description='Get latest release of a project from a specified repository.') | |
parser.add_argument('-r', '--repo', required=True, help='repository with release - i.e. python3 get_latest_release.py -r \'docker/compose\'') | |
return parser.parse_args().repo | |
def get_latest_release(repo): | |
req = requests.get("https://api.github.com/repos/%s/releases/latest" % repo) | |
return req.json()['tag_name'] | |
print(get_latest_release(parse_arg())) | |
# Usage | |
# python3 get_latest_version.py --repo 'docker/compose' | |
# 1.22.0 | |
# Tested with 3.5.2 and 3.6.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment