Skip to content
Snippets Groups Projects
Verified Commit dc6f2e4f authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Added script to check if a given version is the latest

parent 60758358
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
import json
import subprocess
......
#!/usr/bin/env python3
import argparse
import json
import sys
from distutils.version import StrictVersion
def main(current, releases_json):
try:
version = StrictVersion(current)
except ValueError:
print("Version number '{}' isn't valid".format(current))
sys.exit(1)
releases = json.loads(releases_json)
latest_release = releases["releases"][0]["id"]
if version != latest_release:
print(
"Version number '{}' doesn't match latest release {}".format(
current, latest_release
)
)
sys.exit(1)
print("Version number '{}' is latest release!".format(current))
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="""
Exit with code 0 if the given version matches the latest one
fron the list of releases found in releases_json. Primary use
is to check whether the current version can be safely pushed
as the latest one on the docker Hub.
"""
)
parser.add_argument("current", help="Current version")
parser.add_argument("releases_json", type=argparse.FileType("r"))
args = parser.parse_args()
main(args.current, args.releases_json.read())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment