/ scripts / bump-server-chart.sh
bump-server-chart.sh
 1  #!/usr/bin/env bash
 2  # Copyright 2026 Alibaba Group Holding Ltd.
 3  #
 4  # Licensed under the Apache License, Version 2.0 (the "License");
 5  # you may not use this file except in compliance with the License.
 6  # You may obtain a copy of the License at
 7  #
 8  #     http://www.apache.org/licenses/LICENSE-2.0
 9  #
10  # Unless required by applicable law or agreed to in writing, software
11  # distributed under the License is distributed on an "AS IS" BASIS,
12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  # See the License for the specific language governing permissions and
14  # limitations under the License.
15  
16  # Bump server.image.tag in opensandbox-server Helm values (only that field).
17  # Usage from repo root:
18  #   ./scripts/bump-server-chart.sh v0.1.9
19  #   ./scripts/bump-server-chart.sh 0.1.9
20  
21  set -euo pipefail
22  
23  REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
24  cd "$REPO_ROOT"
25  
26  NEW_VERSION="${1:-}"
27  if [ -z "$NEW_VERSION" ]; then
28    echo "Usage: $0 VERSION" >&2
29    exit 1
30  fi
31  
32  if [[ ! "$NEW_VERSION" =~ ^v ]]; then
33    NEW_VERSION="v${NEW_VERSION}"
34  fi
35  
36  FILE="kubernetes/charts/opensandbox-server/values.yaml"
37  if [ ! -f "$FILE" ]; then
38    echo "Error: missing $FILE" >&2
39    exit 1
40  fi
41  
42  # Match tag line immediately after opensandbox/server repository (not gateway/ingress).
43  SERVER_REPO='repository: sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/server'
44  if ! grep -qF "$SERVER_REPO" "$FILE"; then
45    echo "Error: expected server repository line not found in $FILE" >&2
46    exit 1
47  fi
48  
49  perl -i -0pe 's{
50    (repository:\s+sandbox-registry\.cn-zhangjiakou\.cr\.aliyuncs\.com/opensandbox/server\n
51     \s+tag:\s+")[^"]+(")
52  }{$1'"$NEW_VERSION"'$2}x' "$FILE"
53  
54  echo "Updated $FILE: server.image.tag -> $NEW_VERSION"