curl -sL https://api.github.com/repos/${1}/releases/latest | grep '"tag_name":' | cut -d'"' -f4
curl -sL https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | cut -d'"' -f4
封装
get_latest_release() {
curl -sL "https://api.github.com/repos/${1}/releases/latest" | grep '"tag_name":' | cut -d'"' -f4
}
使用
get_latest_release "docker/compose"
参考:https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c