From ab3fc14c13470ed41355c190b621bf7970999bf0 Mon Sep 17 00:00:00 2001 From: iorebuild Date: Sat, 12 Apr 2025 22:03:31 +0800 Subject: [PATCH] =?UTF-8?q?Release=20v1.6.8=20=E6=B5=8B=E8=AF=95=E7=94=9F?= =?UTF-8?q?=E6=88=90readme.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/AutoRelease.yaml | 74 ++++++++++++++++--------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/.gitea/workflows/AutoRelease.yaml b/.gitea/workflows/AutoRelease.yaml index a1508f8..c1c3bf8 100644 --- a/.gitea/workflows/AutoRelease.yaml +++ b/.gitea/workflows/AutoRelease.yaml @@ -24,6 +24,7 @@ jobs: id: ActionEnv run: | # 正确的变量赋值 + UserToken="${{ secrets.AUTOGENERATE }}" UserName="${{ github.actor }}" UserEmail=$(git log -1 --pretty=format:'%ae') GitRepo="${{ github.repository }}" @@ -31,6 +32,7 @@ jobs: RepoUrl="${{ github.repository }}" # 将变量设置为步骤输出 + echo "ENV_USER_TOKEN=$ServerUrl/$UserToken" >> $GITHUB_OUTPUT echo "ENV_USER_NAME=$UserName" >> $GITHUB_OUTPUT echo "ENV_USER_EMAIL=$UserEmail" >> $GITHUB_OUTPUT echo "ENV_REPO_NAME=$GitRepo" >> $GITHUB_OUTPUT @@ -149,7 +151,7 @@ jobs: - name: 创建Gitea发布 uses: https://git.linuxacme.com/iorebuild/gitea-release-action@main with: - gitea_token: ${{ secrets.AUTOGENERATE }} + gitea_token: ${{ steps.ActionEnv.outputs.ENV_USER_TOKEN }} gitea_instance_url: ${{ steps.ActionEnv.outputs.ENV_SERVER_URL }} repository: ${{ steps.ActionEnv.outputs.ENV_REPO_NAME }} name: ${{ steps.parse-release.outputs.title }} @@ -180,6 +182,7 @@ jobs: id: ActionEnv run: | # 正确的变量赋值 + UserToken="${{ secrets.AUTOGENERATE }}" UserName="${{ github.actor }}" UserEmail=$(git log -1 --pretty=format:'%ae') GitRepo="${{ github.repository }}" @@ -187,6 +190,7 @@ jobs: RepoUrl="${{ github.repository }}" # 将变量设置为步骤输出 + echo "ENV_USER_TOKEN=$ServerUrl/$UserToken" >> $GITHUB_OUTPUT echo "ENV_USER_NAME=$UserName" >> $GITHUB_OUTPUT echo "ENV_USER_EMAIL=$UserEmail" >> $GITHUB_OUTPUT echo "ENV_REPO_NAME=$GitRepo" >> $GITHUB_OUTPUT @@ -231,44 +235,44 @@ jobs: echo "README.md does not exist." fi - # - name: 添加工程名字到README.md - # run: | - # REPO_NAME="ActionDemo" - # if [ -f "README.md" ]; then - # TEMP=$(cat README.md) - # echo "$REPO_NAME" > README.md - # echo "$TEMP" >> README.md - # else - # echo "$REPO_NAME" > README.md - # fi + - name: 添加工程名字到README.md + run: | + REPO_NAME="ActionDemo" + if [ -f "README.md" ]; then + TEMP=$(cat README.md) + echo "$REPO_NAME" > README.md + echo "$TEMP" >> README.md + else + echo "$REPO_NAME" > README.md + fi - # - name: Fetch Gitea Releases - # id: fetch-releases - # run: | - # # 使用 Gitea API 获取所有 Release 信息 - # releases=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases") + - name: Fetch Gitea Releases + id: fetch-releases + run: | + # 使用 Gitea API 获取所有 Release 信息 + releases=$(curl -s -H "Authorization: token ${{ steps.ActionEnv.outputs.ENV_USER_TOKEN }}" "$GITEA_API_URL/repos/$GITEA_OWNER/$GITEA_REPO/releases") - # # 将 JSON 数据解析为数组 - # releases_array=$(echo "$releases" | jq -c '.[]') + # 将 JSON 数据解析为数组 + releases_array=$(echo "$releases" | jq -c '.[]') - # # 按发布时间排序 - # sorted_releases=$(echo "$releases_array" | jq -s 'sort_by(.published_at)') + # 按发布时间排序 + sorted_releases=$(echo "$releases_array" | jq -s 'sort_by(.published_at)') - # # 生成 Markdown 内容 - # markdown_content="# Releases\n\n" - # while read -r release; do - # tag_name=$(echo "$release" | jq -r '.tag_name') - # published_at=$(echo "$release" | jq -r '.published_at') - # body=$(echo "$release" | jq -r '.body') + # 生成 Markdown 内容 + markdown_content="# Releases\n\n" + while read -r release; do + tag_name=$(echo "$release" | jq -r '.tag_name') + published_at=$(echo "$release" | jq -r '.published_at') + body=$(echo "$release" | jq -r '.body') - # markdown_content+=$(printf "## %s (%s)\n\n%s\n\n" "$tag_name" "$published_at" "$body") - # done <<< "$sorted_releases" + markdown_content+=$(printf "## %s (%s)\n\n%s\n\n" "$tag_name" "$published_at" "$body") + done <<< "$sorted_releases" - # # 将内容写入 README.md - # echo "$markdown_content" > README.md + # 将内容写入 README.md + echo "$markdown_content" > README.md - # - name: 提交和推送代码 - # run: | - # git add README.md - # git commit -m "Update README.md" - # git push https://${{ secrets.AUTOGENERATE }}@git.linuxacme.com/${{ github.repository }} + - name: 提交和推送代码 + run: | + git add README.md + git commit -m "Update README.md" + git push https://${{ secrets.AUTOGENERATE }}@git.linuxacme.com/${{ github.repository }}