-
Notifications
You must be signed in to change notification settings - Fork 3
/
update-versions.sh
executable file
·43 lines (34 loc) · 1.69 KB
/
update-versions.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
#!/usr/bin/env bash
set -eu -o pipefail
HELM_VERSION=$(curl -fsL https://api.github.com/repos/helm/helm/releases/latest | jq -r '.tag_name')
KAPP_VERSION=$(curl -fsL https://api.github.com/repos/carvel-dev/kapp/releases/latest | jq -r '.tag_name')
KBLD_VERSION=$(curl -fsL https://api.github.com/repos/carvel-dev/kbld/releases/latest | jq -r '.tag_name')
KUBECTL_VERSION=$(curl -fsL https://dl.k8s.io/release/stable.txt)
kustomize_release=$(curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases | /usr/bin/jq -r '.[].tag_name | select(contains("kustomize"))' |
sort -rV | head -n 1)
KUSTOMIZE_VERSION=$(basename "${kustomize_release}")
here=$(dirname "$(readlink -f "$0")")
KUBECTL_SEMVER="${KUBECTL_VERSION//v/}"
KUBECTL_SEMVER_MINOR=$(echo "${KUBECTL_SEMVER}" | sed -e 's/\.[0-9]*$//')
cat >"${here}/VERSIONS" <<EOF
HELM_VERSION=${HELM_VERSION}
KAPP_VERSION=${KAPP_VERSION}
KBLD_VERSION=${KBLD_VERSION}
KUBECTL_SEMVER=${KUBECTL_SEMVER}
KUBECTL_SEMVER_MINOR=${KUBECTL_SEMVER_MINOR}
KUBECTL_VERSION=${KUBECTL_VERSION}
KUSTOMIZE_VERSION=${KUSTOMIZE_VERSION}
EOF
apko_yaml="${here}/apko.yaml"
yq -Y -i ".environment.HELM_VERSION = \"${HELM_VERSION}\"" "${apko_yaml}"
yq -Y -i ".environment.KAPP_VERSION = \"${KAPP_VERSION}\"" "${apko_yaml}"
yq -Y -i ".environment.KBLD_VERSION = \"${KBLD_VERSION}\"" "${apko_yaml}"
yq -Y -i ".environment.KUBECTL_VERSION = \"${KUBECTL_VERSION}\"" "${apko_yaml}"
yq -Y -i ".environment.KUSTOMIZE_VERSION = \"${KUSTOMIZE_VERSION}\"" "${apko_yaml}"
melange_yaml="${here}/melange.yaml"
yq -Y -i ".package.version = \"${KUBECTL_SEMVER}\"" "${melange_yaml}"
tmpdir=$(mktemp -d)
trap 'rm -rf $tmpdir' EXIT
cd "${tmpdir}"
"${here}/download.sh"
sha256sum -- * >"${here}/DIGESTS"