From faa0785fa1fcfbdb874ff114d6b69c420122a229 Mon Sep 17 00:00:00 2001 From: AkashiCoin Date: Fri, 11 Oct 2024 16:18:42 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B3=20chore(update=5Fversion):=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E6=80=A7=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=89=88=E6=9C=AC=20(#1691)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐳 chore(update_version): 支持选择性的更新版本 * 🐳 chore: 替换邮箱格式 --- ...date_version.yml => update_version_pr.yml} | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) rename .github/workflows/{update_version.yml => update_version_pr.yml} (64%) diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version_pr.yml similarity index 64% rename from .github/workflows/update_version.yml rename to .github/workflows/update_version_pr.yml index 9e788ae7..6f650aa2 100644 --- a/.github/workflows/update_version.yml +++ b/.github/workflows/update_version_pr.yml @@ -1,14 +1,12 @@ name: Update Version on: - pull_request_target: + push: paths: + - .github/workflows/update_version_pr.yml - zhenxun/** - resources/** - bot.py - types: - - opened - - synchronize branches: - main - dev @@ -20,7 +18,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.sha }} + token: ${{ secrets.GH_TOKEN }} - name: Read current version id: read_version @@ -46,20 +44,30 @@ jobs: run: echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Update version file + id: update_version if: steps.check_diff.outputs.version_changed == 'false' run: | current_version="${{ steps.read_version.outputs.current_version }}" commit_hash="${{ steps.get_commit_hash.outputs.commit_hash }}" new_version="v${current_version}-${commit_hash}" + echo "new_version=$new_version" >> $GITHUB_OUTPUT echo "Updating version to: $new_version" echo "__version__: $new_version" > __version__ - git config --global user.name "${{ github.event.pull_request.user.login }}" - git config --global user.email "${{ github.event.pull_request.user.login }}@users.noreply.github.com" - git add __version__ - git remote set-url origin https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git - git commit -m "chore(version): Update version to $new_version" - git push origin HEAD:${{ github.event.pull_request.head.ref }} - name: Check updated version if: steps.check_diff.outputs.version_changed == 'false' run: cat __version__ + + - name: Create or update PR + if: steps.check_diff.outputs.version_changed == 'false' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GH_TOKEN }} + branch: create-pr/update_version + title: ":tada: chore(version): 自动更新版本到 ${{ steps.update_version.outputs.new_version }}" + body: "This PR updates the version file." + commit-message: ":tada: chore(version): Update version to ${{ steps.update_version.outputs.new_version }}" + add-paths: __version__ + author: "AkashiCoin " + committer: "${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>" + labels: automated-update