Release v1.4.9 测试生成readme.md

This commit is contained in:
liyp 2025-04-12 18:31:11 +08:00
parent ddb0a5793d
commit 8a75bc5c5d

View File

@ -211,38 +211,46 @@ jobs:
echo "$REPO_NAME" > README.md
fi
- name: 获取版本发布时间线
id: timeline
- name: Get all releases
id: get-releases
run: |
# 获取提交记录
COMMITS=$(git log --pretty=format:"- %ad - Commit: %s (%h)" --date=iso-strict)
# 获取版本发布记录
TAGS=$(git tag -l)
RELEASES=""
for tag in $TAGS; do
TAG_TIME=$(git show -s --format=%ai $tag)
RELEASES="${RELEASES}- $TAG_TIME - Release: $tag\n"
# 获取所有发布信息,使用 GitHub API
releases=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases")
# 解析发布信息,提取名称、发布时间和发布说明
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"
# 合并并按时间排序
COMBINED_TIMELINE=$(echo -e "$COMMITS\n$RELEASES" | sort -r)
echo "::set-output name=timeline::$COMBINED_TIMELINE"
- name: 将提交记录和release记录输出到readme
- name: Update README.md
run: |
if [ -f "README.md" ]; then
TEMP=$(cat README.md)
release_info="${{ steps.get-releases.outputs.release_info }}"
if [ -f README.md ]; then
# 查找并替换原有的版本发布部分,如果没有则添加到开头
if grep -q "### Release Information" README.md; then
sed -i '/### Release Information/,/^$/d' README.md
fi
{
echo "### Repository Timeline"
echo "${{ steps.timeline.outputs.timeline }}"
echo "### Release Information"
echo "$release_info"
echo ""
echo "$TEMP"
} > README.md
cat README.md
} > temp.md
mv temp.md README.md
else
{
echo "### Repository Timeline"
echo "${{ steps.timeline.outputs.timeline }}"
echo "### Release Information"
echo "$release_info"
} > README.md
fi