Just retrieving the latest release may not what you want - An LTS v1.1.20 maybe released after another LTS v2.0.10
Example to get highest version, not just latest - because an LTS bugfix 1.2.3 could be released after a new major 3.x version
curl https://api.github.com/repos/docker/compose/releases -s | jq -r .[].tag_name | grep '^v*[0-9]\.[0-9]*\.[0-9]*$' | sort -rV | head -n1
sudo apt install jq curl grep coreutils
optional_major_version=[0-9]* && \
optional_prefix=v && \
optional_results=100 && \
project=docker/compose && \
curl https://api.github.com/repos/${project}/releases?per_page${optional_results:-100} -s \
| jq -r .[].tag_name \
| grep "^${optional_prefix:-v}*${optional_major_version:-[0-9]*}\.[0-9]*\.[0-9]*\$" \
| sort -rV \
| head -n1
optional_major_version=[0-9]*
- Optional: limit search to specific major version: "2" "[7-8]", default: [0-9]*
optional_prefix=v
- Optional: inlcude an optional version prefix: "v", "b", "V", default: v
project=docker/compose
- GitHub project, for which to retrieve release information
curl https://api.github.com/repos/${project}/releases -s
- Fetch release info from GitHub project
-s
- do not show progress bar or any other outputjq -r .[].tag_name
- Extract all tag names from returned JSON
grep "^${optional_prefix:-v}*${optional_major_version:-[0-9]*}\.[0-9]*\.[0-9]*\$"
- Show only version tags in the form 1.2.3 or v3.1.22
sort -rn
- sort output reversed and by version
head -n1
- display only the first row - the highest version number
# find latest docker-compose v1 release
curl https://api.github.com/repos/docker/compose/releases -s | jq -r .[].tag_name | grep '^v*1\.[0-9]*\.[0-9]*$' -m1
# find latest docker compose v2 release
curl https://api.github.com/repos/docker/compose/releases -s | jq -r .[].tag_name | grep '^v*2\.[0-9]*\.[0-9]*$' -m1