This commit is contained in:
parent
7d7d6af56f
commit
31f04e11d3
33
action.yaml
33
action.yaml
|
|
@ -30,33 +30,44 @@ runs:
|
||||||
current_date=$(date +"%Y.%m.%d" | sed 's/\.0/\./g')
|
current_date=$(date +"%Y.%m.%d" | sed 's/\.0/\./g')
|
||||||
echo "current_date=$current_date"
|
echo "current_date=$current_date"
|
||||||
|
|
||||||
echo "curl -H 'Authorization:token ${{ inputs.token }}' ${{ inputs.server_url }}/api/v1/repos/${{ gitea.repository }}/releases"
|
echo "正在调用API: ${{ inputs.server_url }}/api/v1/repos/${{ inputs.repository }}/releases"
|
||||||
# 获取所有发布版本号
|
# 获取所有发布版本号
|
||||||
json=''
|
json=''
|
||||||
json=$(curl -H 'Authorization:token ${{ inputs.token }}' ${{ inputs.server_url }}/api/v1/repos/${{ gitea.repository }}/releases)
|
json=$(curl -s -H 'Authorization:token ${{ inputs.token }}' ${{ inputs.server_url }}/api/v1/repos/${{ inputs.repository }}/releases)
|
||||||
echo "json=$json"
|
echo "API响应长度: ${#json}"
|
||||||
|
echo "API响应前100字符: ${json:0:100}"
|
||||||
|
|
||||||
# 检查是否存在当前日期的版本
|
# 检查是否存在当前日期的版本
|
||||||
if [ -n "$json" ]; then
|
if [ -n "$json" ] && [ "$json" != "[]" ]; then
|
||||||
# 提取所有标签名
|
# 尝试使用jq工具解析JSON(更可靠)
|
||||||
|
if command -v jq &> /dev/null; then
|
||||||
|
echo "使用jq解析JSON"
|
||||||
|
tags=$(echo "$json" | jq -r '.[].tag_name')
|
||||||
|
else
|
||||||
|
# 回退到使用grep解析
|
||||||
|
echo "使用grep解析JSON"
|
||||||
tags=$(echo $json | grep -oP '"tag_name"\s*:\s*"\K[^"]*')
|
tags=$(echo $json | grep -oP '"tag_name"\s*:\s*"\K[^"]*')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "提取到的标签数量: $(echo "$tags" | wc -l)"
|
||||||
|
echo "前5个标签: $(echo "$tags" | head -5)"
|
||||||
|
|
||||||
# 过滤出当前日期的版本
|
# 过滤出当前日期的版本
|
||||||
date_tags=$(echo "$tags" | grep "^$current_date")
|
date_tags=$(echo "$tags" | grep "^$current_date")
|
||||||
echo "date_tags=$date_tags"
|
echo "当前日期的标签: $date_tags"
|
||||||
|
|
||||||
if [ -n "$date_tags" ]; then
|
if [ -n "$date_tags" ]; then
|
||||||
# 计算当前日期版本的数量
|
# 计算当前日期版本的数量
|
||||||
count=$(echo "$date_tags" | wc -l)
|
count=$(echo "$date_tags" | wc -l)
|
||||||
# 如果有多个版本,添加数字后缀
|
echo "当前日期版本数量: $count"
|
||||||
if [ $count -gt 0 ]; then
|
# 版本号格式为日期-数字
|
||||||
version="$current_date-$count"
|
version="$current_date-$count"
|
||||||
else
|
else
|
||||||
|
# 没有当前日期的版本,使用初始版本号
|
||||||
version="$current_date"
|
version="$current_date"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
version="$current_date"
|
echo "未获取到发布版本信息,使用初始版本号"
|
||||||
fi
|
|
||||||
else
|
|
||||||
version="$current_date"
|
version="$current_date"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue