修改发布脚本
This commit is contained in:
parent
fdfaf3a907
commit
8428129e81
43
action.yaml
43
action.yaml
|
|
@ -26,27 +26,38 @@ runs:
|
||||||
id: get_version
|
id: get_version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
# 获取当前日期作为基础版本号
|
||||||
|
current_date=$(date +"%Y.%m.%d" | sed 's/\.0/\./g')
|
||||||
|
echo "current_date=$current_date"
|
||||||
|
|
||||||
|
# 获取所有发布版本号
|
||||||
json=''
|
json=''
|
||||||
echo 'curl -H 'Authorization:token ${{ inputs.token }}' ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/latest'
|
json=$(curl -H 'Authorization:token ${{ inputs.token }}' ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases)
|
||||||
json=$(curl -H 'Authorization:token ${{ inputs.token }}' ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/latest)
|
|
||||||
|
|
||||||
if [ -n "$json" ] && echo $json|grep -q "tag_name"; then
|
# 检查是否存在当前日期的版本
|
||||||
last_version=$(echo $json | grep -oP '"tag_name"\s*:\s*"\K[^"]*')
|
if [ -n "$json" ]; then
|
||||||
echo "last_version=$last_version"
|
# 提取所有标签名
|
||||||
|
tags=$(echo $json | grep -oP '"tag_name"\s*:\s*"\K[^"]*')
|
||||||
|
# 过滤出当前日期的版本
|
||||||
|
date_tags=$(echo "$tags" | grep "^$current_date")
|
||||||
|
echo "date_tags=$date_tags"
|
||||||
|
|
||||||
|
if [ -n "$date_tags" ]; then
|
||||||
|
# 计算当前日期版本的数量
|
||||||
|
count=$(echo "$date_tags" | wc -l)
|
||||||
|
# 如果有多个版本,添加数字后缀
|
||||||
|
if [ $count -gt 0 ]; then
|
||||||
|
version="$current_date-$count"
|
||||||
else
|
else
|
||||||
last_version=''
|
version="$current_date"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
version="$current_date"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
version="$current_date"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$last_version" ]; then
|
|
||||||
echo "存在版本号,$last_version"
|
|
||||||
array=(${last_version//./ })
|
|
||||||
array[-1]=$((array[-1]+1))
|
|
||||||
version=${array[*]}
|
|
||||||
version=${version// /.}
|
|
||||||
else
|
|
||||||
echo '不存在版本号'
|
|
||||||
version='1.0.0'
|
|
||||||
fi
|
|
||||||
echo "version=$version"
|
echo "version=$version"
|
||||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue