Release v1.4.9 测试生成readme.md
This commit is contained in:
parent
ddb0a5793d
commit
8a75bc5c5d
@ -211,38 +211,46 @@ jobs:
|
|||||||
echo "$REPO_NAME" > README.md
|
echo "$REPO_NAME" > README.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 获取版本发布时间线
|
- name: Get all releases
|
||||||
id: timeline
|
id: get-releases
|
||||||
run: |
|
run: |
|
||||||
# 获取提交记录
|
# 获取所有发布信息,使用 GitHub API
|
||||||
COMMITS=$(git log --pretty=format:"- %ad - Commit: %s (%h)" --date=iso-strict)
|
releases=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/releases")
|
||||||
# 获取版本发布记录
|
# 解析发布信息,提取名称、发布时间和发布说明
|
||||||
TAGS=$(git tag -l)
|
output=""
|
||||||
RELEASES=""
|
for row in $(echo "${releases}" | jq -r '.[] | @base64'); do
|
||||||
for tag in $TAGS; do
|
_jq() {
|
||||||
TAG_TIME=$(git show -s --format=%ai $tag)
|
echo "${row}" | base64 --decode | jq -r "${1}"
|
||||||
RELEASES="${RELEASES}- $TAG_TIME - Release: $tag\n"
|
}
|
||||||
|
name=$(_jq '.name')
|
||||||
|
published_at=$(_jq '.published_at')
|
||||||
|
body=$(_jq '.body')
|
||||||
|
output="${output}- **${name}** (${published_at}):\n ${body}\n"
|
||||||
done
|
done
|
||||||
|
# 按发布时间倒序排序
|
||||||
|
sorted_output=$(echo -e "${output}" | sort -r)
|
||||||
|
echo "::set-output name=release_info::$sorted_output"
|
||||||
|
|
||||||
# 合并并按时间排序
|
- name: Update README.md
|
||||||
COMBINED_TIMELINE=$(echo -e "$COMMITS\n$RELEASES" | sort -r)
|
|
||||||
echo "::set-output name=timeline::$COMBINED_TIMELINE"
|
|
||||||
|
|
||||||
- name: 将提交记录和release记录输出到readme
|
|
||||||
run: |
|
run: |
|
||||||
if [ -f "README.md" ]; then
|
release_info="${{ steps.get-releases.outputs.release_info }}"
|
||||||
TEMP=$(cat README.md)
|
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 "### Release Information"
|
||||||
echo "${{ steps.timeline.outputs.timeline }}"
|
echo "$release_info"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$TEMP"
|
cat README.md
|
||||||
} > README.md
|
} > temp.md
|
||||||
|
mv temp.md README.md
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo "### Repository Timeline"
|
echo "### Release Information"
|
||||||
echo "${{ steps.timeline.outputs.timeline }}"
|
echo "$release_info"
|
||||||
} > README.md
|
} > README.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user