Last active
August 9, 2019 11:11
-
-
Save melboyce/b95383ace778259c46bbbd43cf6c6da5 to your computer and use it in GitHub Desktop.
bash: latest Docker semver tag for image
This file contains hidden or 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
#!/usr/bin/env bash | |
die() { echo "${1:-hurts}" >&2; exit "${2:-1}"; } | |
hash jq 2>/dev/null || die "missing dep: jq" | |
curl -s https://registry.hub.docker.com/v1/repositories/alpine/tags \ | |
| jq -r '.[].name' \ | |
| grep -E '^[0-9]+\.[0-9]+(\..+)?$' \ | |
| sort -t. -k1,1n -k2,2n -k3,3n \ | |
| tail -n1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment