Skip to content

Instantly share code, notes, and snippets.

@l50
Last active July 23, 2018 04:55
Show Gist options
  • Save l50/db44b128cd599a605bc30e200cdebc26 to your computer and use it in GitHub Desktop.
Save l50/db44b128cd599a605bc30e200cdebc26 to your computer and use it in GitHub Desktop.
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