[Shell] Get Github repo release latest by Shell Script

leehs·2023년 1월 6일
0

Github API 릴리즈 최신버전 가져오기

ex) Kubernetes

link: https://github.com/kubernetes/kubernetes


KUBE_URI="kubernetes/kubernetes"

kube_latest=$(curl -L --silent "https://api.github.com/repos/${KUBE_URI}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's/^.//')

echo $kube_latest

응용, Kubernetes 패키지 다운로드

KUBE_URI="kubernetes/kubernetes"
ARCH="amd64"

DEST=$PWD
DOWNLOAD_DIR="/usr/local/bin"

STABLE_RELEASE="$(curl -sSL https://dl.k8s.io/release/stable.txt)"
echo "Officail stable release kube version = ${STABLE_RELEASE}"

kube_latest=$(curl -L --silent "https://api.github.com/repos/${KUBE_URI}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

echo "Github latest release kube version = $kube_latest"

KUBE_VERSION=$STABLE_RELEASE
echo or
KUBE_VERSION=$kube_latest


cd $DEST
curl -v -LO --remote-name-all "https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/${ARCH}/{kubeadm,kubelet,kubectl}"
chmod +x {kubeadm,kubelet,kubectl}

0개의 댓글