diff --git a/build_push.sh b/build_push.sh index 98c9d39..20a88c8 100644 --- a/build_push.sh +++ b/build_push.sh @@ -153,10 +153,8 @@ build_and_push() { elif [ -n "${CI_COMMIT_BRANCH:-}" ]; then if [ "$CI_COMMIT_BRANCH" = "main" ] || [ "$CI_COMMIT_BRANCH" = "master" ]; then # 主干分支 - local short_sha=$(echo "$CI_COMMIT_SHA" | cut -c1-8) - build_args="-t $SWR_REPO:latest -t $SWR_REPO:$short_sha" + build_args="-t $SWR_REPO:latest" track_image "$SWR_REPO:latest" - track_image "$SWR_REPO:$short_sha" elif is_semver_like "$CI_COMMIT_BRANCH" && echo "$CI_COMMIT_BRANCH" | grep -q '\.'; then # 语义化分支 → 生成带 v 的多级标签; 仅当包含 '.' 时才生成多级标签(如 v1.2.3 → v1.2, v1) TAGS=$(generate_version_tags "$CI_COMMIT_BRANCH" "$SWR_REPO") @@ -169,10 +167,8 @@ build_and_push() { else # 普通分支或纯数字(如 12, feature-x)→ 单标签 + sha local safe_branch=$(sanitize_label "$CI_COMMIT_BRANCH") - local short_sha=$(echo "$CI_COMMIT_SHA" | cut -c1-8) - build_args="-t $SWR_REPO:$safe_branch -t $SWR_REPO:$short_sha" + build_args="-t $SWR_REPO:$safe_branch" track_image "$SWR_REPO:$safe_branch" - track_image "$SWR_REPO:$short_sha" fi echo ""