From 789ff17f58fe3fa7c848504613ca3402eb548a58 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 30 May 2025 16:28:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E5=8E=9F=E6=9C=89?= =?UTF-8?q?=E6=A0=87=E5=87=86ci=E7=9A=84tag=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E8=BF=87=E6=BB=A4=E6=8E=89=E6=90=BA=E5=B8=A6?= =?UTF-8?q?=5Fsky=E5=90=8E=E7=BC=80=E7=9A=84tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tag_generator.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tag_generator.sh b/tag_generator.sh index 27e39182..f148c1e1 100755 --- a/tag_generator.sh +++ b/tag_generator.sh @@ -10,17 +10,21 @@ echo "PRIVATE-TOKEN: $TOKEN $URL/projects/$PROJECT_ID/repository/tags" tags_json=$(curl -H "Content-Type: application/json" -H "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/tags") #echo "tags_json:$tags_json\n" tags=$(echo "$tags_json" | jq -r '.[].name') + +# 只保留不带 _sky 后缀的 tag 作为最新 tag +plain_tags=$(echo "$tags" | grep -v '_sky$') +latest_tag=$(echo "$plain_tags" | head -n 1) + tags_length=$(echo "$tags_json" | jq -r 'length') if [ "$tags_length" -lt 1 ]; then next_tag="v1.0.0" else - newest_tag=$(echo "$tags" | head -n 1) - IFS='.' read -r major minor patch <<< "$newest_tag" + IFS='.' read -r major minor patch <<< "$latest_tag" major="${major#v}" compare_json="" if [[ "$1" == "generate_tag" ]];then - echo "generate_tag:$newest_tag-to-master\n" - compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=$newest_tag&to=master") + echo "generate_tag:$latest_tag-to-master\n" + compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=$latest_tag&to=master") elif [[ "$1" == "generate_version" ]]; then echo "generate_version:master-to-$CI_COMMIT_BRANCH\n" compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=master&to=$CI_COMMIT_BRANCH") @@ -45,9 +49,9 @@ else done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, message: .message}') next_tag="v$major.$new_minor.$new_patch" fi -echo "New Tag:$newest_tag;New version: $next_tag;command: $1" +echo "New Tag:$latest_tag;New version: $next_tag;command: $1" if [[ "$1" == "generate_tag" ]];then - if [ "$next_tag" == "$newest_tag" ]; then + if [ "$next_tag" == "$latest_tag" ]; then echo "no change from master,skip to generate tag" exit 0 fi