-
Notifications
You must be signed in to change notification settings - Fork 88
/
set-version.sh
executable file
·25 lines (20 loc) · 1.01 KB
/
set-version.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
#!/bin/bash
VERSION=$1
PLUGIN_VERSION=$2
if [[ -z "${VERSION}" ]] || [[ "${VERSION}" == "-h" ]] || [[ "${VERSION}" == "--help" ]]; then
echo "set-version.sh <version> [<appVersion>] - Update the chart version and regenerate generated content"
echo
echo " <version> The version number to use for the chart."
echo " <appVersion> The app version number to use for the chart (default to latest release)."
fi
if [[ -z "${PLUGIN_VERSION}" ]]; then
PLUGIN_VERSION=$(gh release list --repo grafana/grafana-k8s-plugin --limit 1 --json name --jq '.[].name')
# shellcheck disable=SC2181
if [[ $? -ne 0 ]]; then
echo "Failed to get latest Grafana Kubernetes plugin version. This functionality is only available for Grafana Labs employees."
exit 1
fi
fi
CHART_FILE=Chart.yaml
yq e ".version = \"${VERSION}\"" "${CHART_FILE}" > "${CHART_FILE}.new" && mv "${CHART_FILE}.new" "${CHART_FILE}"
yq e ".appVersion = \"${PLUGIN_VERSION}\"" "${CHART_FILE}" > "${CHART_FILE}.new" && mv "${CHART_FILE}.new" "${CHART_FILE}"