Skip to content

Commit

Permalink
chore: add update-chart scripts (#118)
Browse files Browse the repository at this point in the history
* chore: add update-greptimedb-version scripts

* refactor: refactor update-chart scripts and merge to one function impl update chart

* chore: revert appVersion

* chore: delete log

* chore: update operator chart version

* chore: add use 'update-chart' example

* chore: add use 'update-chart' example
  • Loading branch information
daviderli614 authored Mar 25, 2024
1 parent ee617c2 commit 2cc9ae9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 8 deletions.
52 changes: 52 additions & 0 deletions .github/scripts/update-chart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

CHART="$1"
VERSION="$2"

function update_chart() {
if [ -z "$CHART" ] || [ -z "$VERSION" ]; then
echo "Error: Missing required arguments CHART or VERSION."
exit 1
fi

if [[ "$CHART" != "greptimedb-standalone" && "$CHART" != "greptimedb-operator" && "$CHART" != "greptimedb-cluster" ]]; then
echo "Error: Invalid CHART value: "$CHART"."
exit 1
fi

if [[ ! "$VERSION" =~ ^v && "$CHART" != "greptimedb-operator" ]]; then
echo "Error: VERSION must start with 'v'."
exit 1
fi

chart_file="./charts/"$CHART"/Chart.yaml"
values_file="./charts/"$CHART"/values.yaml"

current_version=$(yq eval '.version' "$chart_file")

major=$(echo "$current_version" | awk -F. '{print $1}')
minor=$(echo "$current_version" | awk -F. '{print $2}')
patch=$(echo "$current_version" | awk -F. '{print $3}')

next_version="$major.$minor.$((patch + 1))"

if [[ "$CHART" == "greptimedb-operator" ]]; then
# The greptimedb-operator image tag not have 'v' prefix.
appVersion=$VERSION
else
appVersion=${VERSION#v}
fi

yq eval ".appVersion = \"$appVersion\"" -i "$chart_file"
yq eval ".version = \"$next_version\"" -i "$chart_file"

echo "The chart $CHART version updated to $next_version successfully."

yq e ".image.tag = \"$VERSION\"" "$values_file" > /tmp/"$CHART"-values-updated.yaml
diff -U0 -w -b --ignore-blank-lines "$values_file" /tmp/"$CHART"-values-updated.yaml > /tmp/"$CHART"-values.diff
patch "$values_file" < /tmp/"$CHART"-values.diff

echo "The chart $CHART image updated to $VERSION successfully."
}

update_chart
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ check-crds: crds ## Check crd
@git diff --quiet || \
(echo "Need to update crds, please run 'make crds'"; \
exit 1)

# For example: make update-chart CHART=${CHART_NAME} VERSION=${IMAGE_TAG}
# make update-chart CHART=greptimedb-standalone VERSION=v0.7.2
# make update-chart CHART=greptimedb-cluster VERSION=v0.7.2
# make update-chart CHART=greptimedb-operator VERSION=0.1.0-alpha.23 # [the greptimedb-operator image tag not have 'v' prefix]
.PHONY: update-chart
update-chart: ## Run update chart
.github/scripts/update-chart.sh $(CHART) $(VERSION)
14 changes: 7 additions & 7 deletions charts/greptimedb-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kubeVersion: ">=1.18.0-0"
description: The greptimedb-operator Helm chart for Kubernetes
name: greptimedb-operator
appVersion: 0.1.0-alpha.23
version: 0.1.10
version: 0.1.11
type: application
home: https://github.com/GreptimeTeam/greptimedb-operator
sources:
Expand All @@ -13,9 +13,9 @@ keywords:
- database
- greptimedb
maintainers:
- name: daviderli614
email: [email protected]
url: https://github.com/daviderli614
- name: zyy17
email: [email protected]
url: https://github.com/zyy17
- name: daviderli614
email: [email protected]
url: https://github.com/daviderli614
- name: zyy17
email: [email protected]
url: https://github.com/zyy17
2 changes: 1 addition & 1 deletion charts/greptimedb-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The greptimedb-operator Helm chart for Kubernetes

![Version: 0.1.10](https://img.shields.io/badge/Version-0.1.10-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0-alpha.23](https://img.shields.io/badge/AppVersion-0.1.0--alpha.23-informational?style=flat-square)
![Version: 0.1.11](https://img.shields.io/badge/Version-0.1.11-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0-alpha.23](https://img.shields.io/badge/AppVersion-0.1.0--alpha.23-informational?style=flat-square)

## Source Code
- https://github.com/GreptimeTeam/greptimedb-operator
Expand Down

0 comments on commit 2cc9ae9

Please sign in to comment.