-
Notifications
You must be signed in to change notification settings - Fork 12
/
release_helm.sh
executable file
·57 lines (44 loc) · 1.29 KB
/
release_helm.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
#!/bin/bash
# Example: ./release_helm.sh -v version -u repo_uri
set -e
usage() {
echo "usage: ${0} [-v <version>] -u <repo_uri> [-h]"
echo " -v <version> Chart version"
echo " -u <repo_uri> Container registry repo"
echo " -h Print this help message"
}
while getopts "v:u:h" flag
do
case "${flag}" in
v) version=${OPTARG};;
u) repo_uri=${OPTARG};;
h) usage; exit 0;;
*) usage; exit 1;;
esac
done
if [ -z "${version}" ] || [ -z "${repo_uri}" ]; then
echo "Error: Both repo_uri and version must be set. Use -u <repo_uri> to specify the repository URI and -v <version> to specify the version."
exit 1
fi
HELM_PATH="helm"
RELEASE_PATH="helm-releases"
mkdir -p $RELEASE_PATH
chart() {
CHART_NAME=$1
shift 1
CHART_VERSION=$1
shift 1
OCI_REPO=$1
shift 1
CHART_TARGET="${CHART_NAME}-${CHART_VERSION}.tgz"
echo "Packaging chart ${CHART_NAME} as ${CHART_TARGET}."
helm package -d "${RELEASE_PATH}" "${HELM_PATH}/${CHART_NAME}"
echo "Pushing helm-${CHART_TARGET} to Container registry - ${OCI_REPO}"
helm push "${RELEASE_PATH}/helm-${CHART_TARGET}" "${OCI_REPO}"
echo '---'
}
for dirpath in "${HELM_PATH}"/* ; do
[ ! -d "${dirpath}" ] && continue
chart "$(basename "${dirpath}")" "${version}" "oci://${repo_uri}"
done
rm -rf ${RELEASE_PATH}