自动版本发布
Some checks failed
自动版本发布 / create-readme (push) Failing after 11s

This commit is contained in:
liyp 2025-04-10 16:49:32 +08:00
parent 2496fca391
commit 05c3d0270b

View File

@ -1,4 +1,4 @@
name: 自动生成README.md文件 name: 自动版本发布
on: on:
push: push:
@ -9,7 +9,7 @@ jobs:
create-readme: create-readme:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'AutoGenerateREADME.md')" if: "!contains(github.event.head_commit.message, 'AutoRelease.md')"
steps: steps:
- name: 删除本地仓库副本 - name: 删除本地仓库副本
@ -29,35 +29,16 @@ jobs:
CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}" CLEAN_REPO_URL="${CLEAN_REPO_URL#https://}"
git clone "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" . git clone "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" .
- name: 创建README.md - name: 生成版本号
id: version
run: | run: |
if [ -f README.md ]; then VERSION=$(date +'%Y%m%d%H%M%S')
rm README.md echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
- name: 生成提交历史记录 - name: 创建 Release
id: commit-history
run: | run: |
COMMIT_HISTORY=$(git log --pretty=format:"- %cd %h %an: %s" --date=short) gh release create v${{ steps.version.outputs.version }} --generate-notes
echo "::set-output name=commit_history::$COMMIT_HISTORY"
- name: 生成Release历史记录
id: release-history
run: |
RELEASE_HISTORY=$(gh release list --limit 100 --json tagName,publishedAt,body --template '{{range .}}- {{.publishedAt}} {{.tagName}}: {{.body}}{{"\n"}}{{end}}')
echo "::set-output name=release_history::$RELEASE_HISTORY"
- name: 将提交和Release记录添加到README.md
run: |
{
echo
echo "# 提交历史记录"
echo "${{ steps.commit-history.outputs.commit_history }}"
echo
echo "# Release历史记录"
echo "${{ steps.release-history.outputs.release_history }}"
} >> README.md
- name: 重新提交仓库 - name: 重新提交仓库
env: env:
GITEA_TOKEN: ${{ secrets.AUTOGENERATE }} GITEA_TOKEN: ${{ secrets.AUTOGENERATE }}
@ -71,6 +52,6 @@ jobs:
if git diff --staged --quiet; then if git diff --staged --quiet; then
echo "No changes to commit." echo "No changes to commit."
else else
git commit -m "AutoGenerateREADME.md" git commit -m "AutoRelease.md"
git push "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}" git push "https://${GITEA_TOKEN}@${CLEAN_REPO_URL}"
fi fi