-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathupdate.sh
executable file
·69 lines (58 loc) · 2.13 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
set -e -x
if [ "$#" -lt 2 ]; then
echo "Usage: ./update.sh <argo|argocd|kubectl-argo-rollouts> VERSION"
exit 1
fi
CLI_NAME="$1"
VERSION="$2"
BREW_VERSION="$3"
if [ "${CLI_NAME}" = "argocd" ]; then
URL_BASE="https://github.com/argoproj/argo-cd/releases/download"
CLASSNAME="Argocd"
DESC="GitOps Continuous Delivery for Kubernetes"
elif [ "${CLI_NAME}" = "argo" ]; then
URL_BASE="https://github.com/argoproj/argo/releases/download"
CLASSNAME="Argo"
DESC="Get stuff done with container-native workflows for Kubernetes."
elif [ "${CLI_NAME}" = "kubectl-argo-rollouts" ]; then
URL_BASE="https://github.com/argoproj/argo-rollouts/releases/download"
CLASSNAME="KubectlArgoRollouts"
DESC="Kubectl Argo Rollouts Plugin."
else
echo "Unsupported binary: ${CLI_NAME}"
exit 1
fi
# OSX
OSX_CLI_NAME="${CLI_NAME}-darwin-amd64"
OSX_BINPATH="/tmp/${OSX_CLI_NAME}"
curl --fail -L -o ${OSX_BINPATH} -s "${URL_BASE}/${VERSION}/${OSX_CLI_NAME}" || (echo "Failed to curl (${URL_BASE}/${VERSION}/${OSX_CLI_NAME})" && exit 1)
OSX_SHA256=$(shasum -a 256 "${OSX_BINPATH}" | awk '{print $1}')
# Linux
LINUX_CLI_NAME="${CLI_NAME}-linux-amd64"
LINUX_BINPATH="/tmp/${LINUX_CLI_NAME}"
curl --fail -L -o ${LINUX_BINPATH} -s "${URL_BASE}/${VERSION}/${LINUX_CLI_NAME}" || (echo "Failed to curl (${URL_BASE}/${VERSION}/${LINUX_CLI_NAME})" && exit 1)
LINUX_SHA256=$(shasum -a 256 "${LINUX_BINPATH}" | awk '{print $1}')
CLASS_POSTFIX=$(echo ${BREW_VERSION} | tr -d '.')
CLASS_POSTFIX=$(echo ${CLASS_POSTFIX} | sed "s/@/AT/g")
TEMPLATE="# This is an auto-generated file. DO NOT EDIT
class ${CLASSNAME}${CLASS_POSTFIX} < Formula
desc \"${DESC}\"
homepage \"https://argoproj.io\"
baseurl = \"${URL_BASE}\"
version \"${VERSION}\"
if OS.mac?
kernel = \"darwin\"
sha256 \"${OSX_SHA256}\"
elsif OS.linux?
kernel = \"linux\"
sha256 \"${LINUX_SHA256}\"
end
@@bin_name = \"${CLI_NAME}-\" + kernel + \"-amd64\"
url baseurl + \"/${VERSION}/\" + @@bin_name
def install
bin.install @@bin_name
mv bin/ + @@bin_name.to_s, bin/\"${CLI_NAME}\"
end
end"
echo "${TEMPLATE}" > "${CLI_NAME}${BREW_VERSION}.rb"