1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- # Bump egress or execd image version across the entire project.
16+ # Bump component image versions across the project (image refs like component:vX.Y.Z).
17+ # For ingress, also updates gateway image tag in kubernetes/charts/opensandbox-server/values.yaml.
1718# Usage: from repo root:
1819# ./scripts/bump-component-version.sh egress v1.0.2
1920# ./scripts/bump-component-version.sh execd v1.0.7
21+ # ./scripts/bump-component-version.sh ingress v1.0.6
2022# ./scripts/bump-component-version.sh v1.0.2 # same as: egress v1.0.2
2123
2224set -euo pipefail
2325
2426REPO_ROOT=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
2527cd " $REPO_ROOT "
2628
27- # Parse args: [egress|execd] NEW_VERSION or NEW_VERSION (default egress)
29+ # Parse args: COMPONENT NEW_VERSION or NEW_VERSION (default component: egress)
2830COMPONENT=" "
2931NEW_VERSION=" "
3032if [ $# -eq 1 ]; then
@@ -34,15 +36,16 @@ elif [ $# -eq 2 ]; then
3436 COMPONENT=" $1 "
3537 NEW_VERSION=" $2 "
3638else
37- echo " Usage: $0 [egress|execd] NEW_VERSION" >&2
39+ echo " Usage: $0 [egress|execd|ingress|code-interpreter ] NEW_VERSION" >&2
3840 echo " $0 NEW_VERSION # bumps egress" >&2
3941 echo " Example: $0 egress v1.0.2" >&2
4042 echo " Example: $0 execd 1.0.7" >&2
43+ echo " Example: $0 ingress v1.0.6" >&2
4144 exit 1
4245fi
4346
4447case " $COMPONENT " in
45- egress|execd|code-interpreter) ;;
48+ egress|execd|ingress| code-interpreter) ;;
4649 * )
4750 echo " Error: unsupported component: $COMPONENT " >&2
4851 exit 0
@@ -54,6 +57,33 @@ if [[ ! "$NEW_VERSION" =~ ^v ]]; then
5457 NEW_VERSION=" v${NEW_VERSION} "
5558fi
5659
60+ updated=0
61+
62+ # Helm values: gateway ingress image uses repository + tag (not ingress:vX in one string).
63+ CHART_VALUES=" kubernetes/charts/opensandbox-server/values.yaml"
64+ if [ " $COMPONENT " = " ingress" ]; then
65+ INGRESS_REPO=' repository: sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/ingress'
66+ if [ ! -f " $CHART_VALUES " ]; then
67+ echo " Error: missing $CHART_VALUES " >&2
68+ exit 1
69+ fi
70+ if ! grep -qF " $INGRESS_REPO " " $CHART_VALUES " ; then
71+ echo " Error: expected ingress gateway repository line not found in $CHART_VALUES " >&2
72+ exit 1
73+ fi
74+ tmpfile=" $( mktemp) "
75+ cp " $CHART_VALUES " " $tmpfile "
76+ perl -i -0pe ' s{
77+ (repository:\s+sandbox-registry\.cn-zhangjiakou\.cr\.aliyuncs\.com/opensandbox/ingress\n
78+ \s+tag:\s+")[^"]+(")
79+ }{$1' " $NEW_VERSION " ' $2}x' " $CHART_VALUES "
80+ if ! cmp -s " $CHART_VALUES " " $tmpfile " ; then
81+ echo " Updated $CHART_VALUES (server.gateway.image tag for ingress)"
82+ updated=$(( updated + 1 ))
83+ fi
84+ rm -f " $tmpfile "
85+ fi
86+
5787# Pattern and replacement for this component (e.g. egress:vX.Y.Z -> egress:NEW_VERSION)
5888PATTERN=" ${COMPONENT} :v[0-9]+\.[0-9]+\.[0-9]+"
5989REPLACEMENT=" ${COMPONENT} :${NEW_VERSION} "
@@ -68,8 +98,9 @@ done < <(grep -rEl \
6898 --exclude-dir=.git --exclude-dir=__pycache__ --exclude-dir=.venv --exclude-dir=node_modules \
6999 " $PATTERN " . 2> /dev/null || true)
70100
71- updated=0
72- for f in " ${files[@]} " ; do
101+ # Iterate without "${files[@]}" on an empty array (bash 3.x + set -u can error).
102+ for (( i = 0 ; i < ${# files[@]} ; i++ )) ; do
103+ f=" ${files[$i]} "
73104 [ -f " $f " ] || continue
74105 case " $f " in
75106 * RELEASE_NOTES* ) continue ;;
@@ -81,7 +112,7 @@ for f in "${files[@]}"; do
81112done
82113
83114if [ " $updated " -eq 0 ]; then
84- echo " No files were updated (no matches for $PATTERN )." >&2
115+ echo " No files were updated (nothing matched for component $COMPONENT )." >&2
85116 exit 1
86117fi
87118
0 commit comments