ci: 小版本计算规则修改

This commit is contained in:
Liuyf 2025-02-18 10:29:23 +08:00
parent a785c0777c
commit 1ef8cecc39

View File

@ -27,22 +27,23 @@ else
fi fi
echo "compare_json:$compare_json\n" echo "compare_json:$compare_json\n"
new_patch=$patch new_patch=$patch
new_minor=$minor
while IFS= read -r commit_json; do while IFS= read -r commit_json; do
# 使用 jq 解析每一行的 JSON 对象 # 使用 jq 解析每一行的 JSON 对象
commit_id=$(echo "$commit_json" | jq -r '.id') commit_id=$(echo "$commit_json" | jq -r '.id')
commit_message=$(echo "$commit_json" | jq -r '.message') commit_message=$(echo "$commit_json" | jq -r '.message')
echo "----$commit_message" echo "----$commit_message"
if [[ "$commit_message" =~ ("feat:"*) ]]; then if [[ "$commit_message" =~ ("feat:"*) ]] && [[ $new_minor == $minor ]]; then
((minor++)) ((new_minor++))
# new_patch=0 # new_patch=0
break # break
elif [[ "$commit_message" =~ ("fix:"*) ]] && [[ $new_patch == $patch ]]; then elif [[ "$commit_message" =~ ("fix:"*) ]]; then
((new_patch++)) ((new_patch++))
elif [[ ! "$commit_message" =~ ("Merge"* | "Revert"*) ]] && [[ $new_patch == $patch ]]; then elif [[ ! "$commit_message" =~ ("Merge"* | "Revert"*) ]]; then
((new_patch++)) ((new_patch++))
fi fi
done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, message: .message}') done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, message: .message}')
next_tag="v$major.$minor.$new_patch" next_tag="v$major.$new_minor.$new_patch"
fi fi
echo "New Tag:$newest_tag;New version: $next_tag;command: $1" echo "New Tag:$newest_tag;New version: $next_tag;command: $1"
if [[ "$1" == "generate_tag" ]];then if [[ "$1" == "generate_tag" ]];then