Files
wehub-resource-sync e0e362d700
SDK Tests / SDK CI (push) Blocked by required conditions
SDK Tests / changes (push) Successful in 2m29s
Real E2E Tests / changes (push) Successful in 2m29s
SDK Tests / Python SDK Tests (sandbox) (push) Waiting to run
SDK Tests / CLI Quality (push) Waiting to run
SDK Tests / CLI Tests (push) Waiting to run
SDK Tests / Python SDK Quality (code-interpreter) (push) Waiting to run
SDK Tests / Python SDK Quality (sandbox) (push) Waiting to run
SDK Tests / Python SDK Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Go SDK Quality And Tests (push) Waiting to run
Deploy Docs Pages / build (push) Has been cancelled
Deploy Docs Pages / deploy (push) Has been cancelled
Real E2E Tests / JavaScript E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Python E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Java E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / C# E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Go E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Real E2E CI (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:33 +08:00

121 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2026 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Bump component image versions across the project (image refs like component:vX.Y.Z).
# For ingress, also updates gateway image tag in kubernetes/charts/opensandbox-server/values.yaml.
# Usage: from repo root:
# ./scripts/bump-component-version.sh egress v1.0.2
# ./scripts/bump-component-version.sh execd v1.0.7
# ./scripts/bump-component-version.sh ingress v1.0.6
# ./scripts/bump-component-version.sh v1.0.2 # same as: egress v1.0.2
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$REPO_ROOT"
# Parse args: COMPONENT NEW_VERSION or NEW_VERSION (default component: egress)
COMPONENT=""
NEW_VERSION=""
if [ $# -eq 1 ]; then
COMPONENT="egress"
NEW_VERSION="$1"
elif [ $# -eq 2 ]; then
COMPONENT="$1"
NEW_VERSION="$2"
else
echo "Usage: $0 [egress|execd|ingress|code-interpreter|image-committer] NEW_VERSION" >&2
echo " $0 NEW_VERSION # bumps egress" >&2
echo "Example: $0 egress v1.0.2" >&2
echo "Example: $0 execd 1.0.7" >&2
echo "Example: $0 ingress v1.0.6" >&2
echo "Example: $0 image-committer v0.1.0" >&2
exit 1
fi
case "$COMPONENT" in
egress|execd|ingress|code-interpreter|image-committer) ;;
*)
echo "Error: unsupported component: $COMPONENT" >&2
exit 0
;;
esac
# Normalize version: ensure 'v' prefix
if [[ ! "$NEW_VERSION" =~ ^v ]]; then
NEW_VERSION="v${NEW_VERSION}"
fi
updated=0
# Helm values: gateway ingress image uses repository + tag (not ingress:vX in one string).
CHART_VALUES="kubernetes/charts/opensandbox-server/values.yaml"
if [ "$COMPONENT" = "ingress" ]; then
INGRESS_REPO='repository: sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/ingress'
if [ ! -f "$CHART_VALUES" ]; then
echo "Error: missing $CHART_VALUES" >&2
exit 1
fi
if ! grep -qF "$INGRESS_REPO" "$CHART_VALUES"; then
echo "Error: expected ingress gateway repository line not found in $CHART_VALUES" >&2
exit 1
fi
tmpfile="$(mktemp)"
cp "$CHART_VALUES" "$tmpfile"
perl -i -0pe 's{
(repository:\s+sandbox-registry\.cn-zhangjiakou\.cr\.aliyuncs\.com/opensandbox/ingress\n
\s+tag:\s+")[^"]+(")
}{$1'"$NEW_VERSION"'$2}x' "$CHART_VALUES"
if ! cmp -s "$CHART_VALUES" "$tmpfile"; then
echo "Updated $CHART_VALUES (server.gateway.image tag for ingress)"
updated=$((updated + 1))
fi
rm -f "$tmpfile"
fi
# Pattern and replacement for this component (e.g. egress:vX.Y.Z -> egress:NEW_VERSION)
PATTERN="${COMPONENT}:v[0-9]+\.[0-9]+\.[0-9]+"
REPLACEMENT="${COMPONENT}:${NEW_VERSION}"
# Do not touch release notes: they document historical image tags and must not be
# rewritten when bumping versions elsewhere.
files=()
while IFS= read -r f; do
[ -n "$f" ] && files+=("$f")
done < <(grep -rEl \
--exclude='*RELEASE_NOTES*' \
--exclude-dir=.git --exclude-dir=__pycache__ --exclude-dir=.venv --exclude-dir=node_modules \
"$PATTERN" . 2>/dev/null || true)
# Iterate without "${files[@]}" on an empty array (bash 3.x + set -u can error).
for ((i = 0; i < ${#files[@]}; i++)); do
f="${files[$i]}"
[ -f "$f" ] || continue
case "$f" in
*RELEASE_NOTES*) continue ;;
esac
if perl -i -pe "s/$PATTERN/$REPLACEMENT/g" "$f" 2>/dev/null; then
echo "Updated $f"
((updated++)) || true
fi
done
if [ "$updated" -eq 0 ]; then
echo "No files were updated (nothing matched for component $COMPONENT)." >&2
exit 1
fi
echo "Done. Bumped $COMPONENT version to $NEW_VERSION in $updated file(s)."