-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathrelease_helm.sh
More file actions
executable file
·64 lines (47 loc) · 1.47 KB
/
release_helm.sh
File metadata and controls
executable file
·64 lines (47 loc) · 1.47 KB
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
#!/bin/bash
# Example: ./release_helm.sh -v version -u repo_uri
set -e
usage() {
echo "usage: ${0} -u <repo_uri> [-h]"
echo " -u <repo_uri> Container registry repo"
echo " -h Print this help message"
}
while getopts "u:h" flag
do
case "${flag}" in
u) repo_uri=${OPTARG};;
h) usage; exit 0;;
*) usage; exit 1;;
esac
done
if [ -z "${repo_uri}" ]; then
echo "Error: repo_uri must be set. Use -u <repo_uri> to specify the repository URI."
exit 1
fi
HELM_PATH="helm"
RELEASE_PATH="helm-releases"
mkdir -p $RELEASE_PATH
chart() {
CHART_NAME=$1
shift 1
OCI_REPO=$1
shift 1
CHART_VERSION=$(grep '^version:' "${HELM_PATH}/${CHART_NAME}/Chart.yaml" | awk '{print $2}' | sed 's/"//g')
if [ -z "${CHART_VERSION}" ]; then
echo "Error: Could not find version in ${HELM_PATH}/${CHART_NAME}/Chart.yaml"
exit 1
fi
CHART_TARGET="${CHART_NAME}-${CHART_VERSION}.tgz"
echo "Updating dependencies of chart ${CHART_NAME}."
helm dependency update "${HELM_PATH}/${CHART_NAME}"
echo "Packaging chart ${CHART_NAME} (version ${CHART_VERSION}) 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}")" "oci://${repo_uri}"
done
rm -rf ${RELEASE_PATH}