Release v1.5.3 测试生成readme.md
This commit is contained in:
parent
9079c05fd9
commit
baf11b2501
@ -211,57 +211,36 @@ jobs:
|
|||||||
echo "$REPO_NAME" > README.md
|
echo "$REPO_NAME" > README.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Get all releases
|
- name: Fetch Gitea Releases
|
||||||
id: get-releases
|
id: fetch-releases
|
||||||
env:
|
env:
|
||||||
GITEA_API_TOKEN: ${{ secrets.GITEA_API_TOKEN }}
|
CURRENT_USER_NAME: "iorebuild"
|
||||||
GITEA_INSTANCE_URL: ${{ secrets.GITEA_INSTANCE_URL }}
|
GITEA_API_URL: https://git.linuxacme.com/api/v1 # 替换为您的 Gitea 实例地址
|
||||||
GITEA_REPO: ${{ secrets.GITEA_REPO }}
|
GITEA_OWNER: CURRENT_USER_NAME # 替换为您的仓库所有者
|
||||||
|
GITEA_REPO: ${{ github.repository }} # 替换为您的仓库名称
|
||||||
|
GITEA_TOKEN: ${{ secrets.AUTOGENERATE }} # 使用 Gitea API 令牌
|
||||||
run: |
|
run: |
|
||||||
set -e # 遇到错误就终止脚本
|
# 使用 Gitea API 获取所有 Release 信息
|
||||||
# 获取所有发布信息,使用 Gitea API
|
releases=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases")
|
||||||
releases=$(curl -s -H "Authorization: token $GITEA_API_TOKEN" \
|
|
||||||
"$GITEA_INSTANCE_URL/api/v1/repos/$GITEA_REPO/releases")
|
# 将 JSON 数据解析为数组
|
||||||
if [ -z "$releases" ]; then
|
releases_array=$(echo "$releases" | jq -c '.[]')
|
||||||
echo "Failed to get releases. Check your API token and instance URL."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# 解析发布信息,提取名称、发布时间和发布说明
|
|
||||||
output=""
|
|
||||||
for row in $(echo "${releases}" | jq -r '.[] | @base64'); do
|
|
||||||
_jq() {
|
|
||||||
echo "${row}" | base64 --decode | jq -r "${1}"
|
|
||||||
}
|
|
||||||
name=$(_jq '.name')
|
|
||||||
published_at=$(_jq '.published_at')
|
|
||||||
body=$(_jq '.body')
|
|
||||||
output="${output}- **${name}** (${published_at}):\n ${body}\n"
|
|
||||||
done
|
|
||||||
# 按发布时间倒序排序
|
|
||||||
sorted_output=$(echo -e "${output}" | sort -r)
|
|
||||||
echo "::set-output name=release_info::$sorted_output"
|
|
||||||
|
|
||||||
- name: Update README.md
|
# 按发布时间排序
|
||||||
run: |
|
sorted_releases=$(echo "$releases_array" | jq -s 'sort_by(.published_at)')
|
||||||
release_info="${{ steps.get-releases.outputs.release_info }}"
|
|
||||||
if [ -f README.md ]; then
|
# 生成 Markdown 内容
|
||||||
# 查找并替换原有的版本发布部分,如果没有则添加到开头
|
markdown_content="# Releases\n\n"
|
||||||
if grep -q "### Release Information" README.md; then
|
while read -r release; do
|
||||||
sed -i '/### Release Information/,/^$/d' README.md
|
tag_name=$(echo "$release" | jq -r '.tag_name')
|
||||||
fi
|
published_at=$(echo "$release" | jq -r '.published_at')
|
||||||
{
|
body=$(echo "$release" | jq -r '.body')
|
||||||
echo "### Release Information"
|
|
||||||
echo "$release_info"
|
markdown_content+=$(printf "## %s (%s)\n\n%s\n\n" "$tag_name" "$published_at" "$body")
|
||||||
echo ""
|
done <<< "$sorted_releases"
|
||||||
cat README.md
|
|
||||||
} > temp.md
|
# 将内容写入 README.md
|
||||||
mv temp.md README.md
|
echo "$markdown_content" > README.md
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "### Release Information"
|
|
||||||
echo "$release_info"
|
|
||||||
} > README.md
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: 提交和推送代码
|
- name: 提交和推送代码
|
||||||
run: |
|
run: |
|
||||||
|
Loading…
Reference in New Issue
Block a user