Skip to content

Instantly share code, notes, and snippets.

@melboyce
Last active August 9, 2019 11:11
Show Gist options
  • Save melboyce/b95383ace778259c46bbbd43cf6c6da5 to your computer and use it in GitHub Desktop.
Save melboyce/b95383ace778259c46bbbd43cf6c6da5 to your computer and use it in GitHub Desktop.
bash: latest Docker semver tag for image
#!/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