How to get software version and release date from Github

Jbn1233
1 min readMay 3, 2020

--

Yes, there’s an API for that

Example:

$ curl -sS https://api.github.com/repos/cri-o/cri-o/releases | jq -r  .[].name
v1.15.4
v1.18.0
v1.17.4
v1.16.6
v1.18.0-rc1
v1.16.4
v1.16.5
...
...
...

I don’t need ALL releases. I just need the latest version.

This result still not OK. Since I need more than one.

$ curl -sS https://api.github.com/repos/cri-o/cri-o/releases/latest | jq -r .name
v1.15.4

I want something like this:

$ ./crio_latest_version.sh
cri-o latest version:
cri-o v1.15.4 May 1, 2020
cri-o v1.16.4 Apr 8, 2020
cri-o v1.16.5 Apr 8, 2020
cri-o v1.16.6 Apr 15, 2020
cri-o v1.17.1 Mar 16, 2020
cri-o v1.17.2 Mar 26, 2020
cri-o v1.17.3 Apr 8, 2020
cri-o v1.17.4 Apr 22, 2020
cri-o v1.18.0 Apr 23, 2020
cri-o v1.18.0-rc1 Apr 15, 2020

So this is a simple script.

#!/bin/bashecho ""
echo "cri-o latest version: "
echo ""
for i in $(curl -m5 -sS https://github.com/cri-o/cri-o/releases | lynx --dump -stdin |grep releases|grep tag|awk -F/ {'print $NF'})
do
if ! [[ "$i" =~ "v1.13" ]] && ! [[ "$i" =~ "v1.14" ]]
then
echo -n "cri-o $i "
curl -sS "https://github.com/cri-o/cri-o/releases/tag/$i"|lynx --dump -stdin -nolist | grep "released this"|awk -F"released this" {'print $2'} | \
awk {'print $1,$2,$3'}
fidoneecho ""

Done.

--

--

Jbn1233
Jbn1233

Written by Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |

No responses yet