diff --git a/.github/workflows/.github/workflows/update-release-badge.yml b/.github/workflows/.github/workflows/update-release-badge.yml new file mode 100644 index 0000000..da270b5 --- /dev/null +++ b/.github/workflows/.github/workflows/update-release-badge.yml @@ -0,0 +1,34 @@ +name: Update Release Badge + +on: + push: + tags: + - 'v*' # 可按需调整 + +jobs: + update-badge: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Get latest tag + id: get_tag + run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Update README badge + run: | + TAG=${{ steps.get_tag.outputs.tag_name }} + BADGE="https://img.shields.io/github/actions/workflow/status/qaiu/netdisk-fast-download/maven.yml?branch=$TAG" + echo "Using badge: $BADGE" + + # 替换 README 中 badge 行(标记行需特殊注释) + sed -i -E "s#(!\[release-badge\]\(.*\))#![release-badge]($BADGE)#" README.md + + - name: Commit and push + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -am "🔄 update release badge for ${{ steps.get_tag.outputs.tag_name }}" || echo "No changes" + git push