fix:调整原有标准ci的tag生成逻辑,过滤掉携带_sky后缀的tag
This commit is contained in:
parent
5d0da71780
commit
789ff17f58
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user