From 07dbe8f0c6b340714e6fd320d81b7be5975876d3 Mon Sep 17 00:00:00 2001 From: zhiyi Date: Thu, 3 Oct 2024 02:33:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-release.yml | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/auto-release.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..5824bf7 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,42 @@ +name: Auto Release on Specific File Update + +on: + push: + workflow_dispatch: + +jobs: + release: + if: ${{ github.event.head_commit.modified.includes('gfw.pac') }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Get commit count for today + id: commit_count + run: | + echo "COMMIT_COUNT=$(git rev-list --count HEAD --since=$(date -I) && echo '.${{ github.run_number }}')" >> $GITHUB_OUTPUT + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: ${{ format('{}{}', (date +%Y%m%d), steps.commit_count.outputs.COMMIT_COUNT) }} + + - name: Get changed file path + id: changed_file_path + run: | + CHANGED_FILE=$(git diff-tree --no-commit-id --name-only -r HEAD | grep -m 1 gfw.pac) + echo "CHANGED_FILE_PATH=$CHANGED_FILE" >> $GITHUB_OUTPUT + + - name: Upload file as release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ steps.changed_file_path.outputs.CHANGED_FILE_PATH }} + asset_name: ${{ steps.changed_file_path.outputs.CHANGED_FILE_PATH | split("/") | last }} \ No newline at end of file