From 10b60eb8c385ba0f8f9ebf1cdf86a22ee4eaacdc Mon Sep 17 00:00:00 2001 From: Moralts Date: Sun, 22 Feb 2026 16:52:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(github/action):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20PR=20=E6=A0=87=E7=AD=BE=E8=A7=A6=E5=8F=91=20action=20?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr.yml | 126 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..a6c26c0 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,126 @@ +name: 'Tauri App Build PR' + +on: + pull_request: + types: [labeled] + branches: + - main + +jobs: + test-tauri: + if: github.event.label.name == '自动构建' + + permissions: + contents: read + pull-requests: write + + strategy: + fail-fast: false + matrix: + include: + - platform: 'macos-latest' + args: '--target aarch64-apple-darwin' + - platform: 'macos-latest' + args: '--target x86_64-apple-darwin' + - platform: 'ubuntu-22.04' + args: '' + - platform: 'windows-latest' + args: '' + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: lts/* + + - run: corepack enable + + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} + + - if: matrix.platform == 'ubuntu-22.04' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + + - run: pnpm install + + - uses: tauri-apps/tauri-action@v0 + id: tauri-build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: ${{ matrix.args }} + + - if: matrix.platform == 'macos-latest' + uses: actions/upload-artifact@v4 + with: + name: tauri-app-${{ matrix.args == '--target aarch64-apple-darwin' && 'macos-arm64' || 'macos-x64' }} + path: | + src-tauri/target/*/release/bundle/**/*.dmg + src-tauri/target/*/release/bundle/**/*.app + if-no-files-found: warn + + - if: matrix.platform == 'ubuntu-22.04' + uses: actions/upload-artifact@v4 + with: + name: tauri-app-linux + path: | + src-tauri/target/release/bundle/**/*.AppImage + src-tauri/target/release/bundle/**/*.deb + if-no-files-found: warn + + - if: matrix.platform == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: tauri-app-windows + path: | + src-tauri/target/release/bundle/**/*.msi + src-tauri/target/release/bundle/**/*.exe + if-no-files-found: warn + + - if: failure() + uses: actions/github-script@v7 + with: + script: | + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `❌ **构建失败** - ${{ matrix.platform }} ${{ matrix.args }}` + }); + await github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: '自动构建' + }); + + outputs: + result: ${{ job.status }} + + notify: + needs: test-tauri + if: always() && needs.test-tauri.result == 'success' + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v7 + with: + script: | + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `✅ **构建完成**\n\n所有平台构建成功,请在 Actions 页面下载产物。` + }); + await github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: '自动构建' + }); From 804f13a2be2043df2a5e9c2ef610997b44c0895e Mon Sep 17 00:00:00 2001 From: Moralts Date: Sun, 22 Feb 2026 16:56:25 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix(github/action):=20=E5=8E=BB=E9=99=A4=20?= =?UTF-8?q?branches=20=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a6c26c0..dd82910 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -3,8 +3,6 @@ name: 'Tauri App Build PR' on: pull_request: types: [labeled] - branches: - - main jobs: test-tauri: From 08ae4c40b307e2c9e87f282cc99ae2fb463d2eab Mon Sep 17 00:00:00 2001 From: Moralts Date: Sun, 22 Feb 2026 16:58:19 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix(github/action):=20=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=A0=87=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index dd82910..6ef8390 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,7 +6,7 @@ on: jobs: test-tauri: - if: github.event.label.name == '自动构建' + if: github.event.label.name == 'Action 构建' permissions: contents: read @@ -94,7 +94,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - name: '自动构建' + name: 'Action 构建' }); outputs: @@ -120,5 +120,5 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - name: '自动构建' + name: 'Action 构建' }); From 8ce7923ef7590a5731ff2588e92477f1e6060205 Mon Sep 17 00:00:00 2001 From: Moralts Date: Sun, 22 Feb 2026 17:14:58 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat(github/action):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr.yml | 83 ++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6ef8390..2ca7561 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,12 +1,12 @@ -name: 'Tauri App Build PR' +name: 'Tauri App Build Test' on: pull_request: - types: [labeled] + types: [opened, labeled] jobs: test-tauri: - if: github.event.label.name == 'Action 构建' + if: github.event.action == 'opened' || github.event.label.name == '需要 Action 构建' permissions: contents: read @@ -18,12 +18,16 @@ jobs: include: - platform: 'macos-latest' args: '--target aarch64-apple-darwin' + name: 'macOS ARM64' - platform: 'macos-latest' args: '--target x86_64-apple-darwin' + name: 'macOS x64' - platform: 'ubuntu-22.04' args: '' + name: 'Linux' - platform: 'windows-latest' args: '' + name: 'Windows' runs-on: ${{ matrix.platform }} steps: @@ -80,29 +84,13 @@ jobs: src-tauri/target/release/bundle/**/*.exe if-no-files-found: warn - - if: failure() - uses: actions/github-script@v7 - with: - script: | - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `❌ **构建失败** - ${{ matrix.platform }} ${{ matrix.args }}` - }); - await github.rest.issues.removeLabel({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - name: 'Action 构建' - }); - outputs: result: ${{ job.status }} + platform: ${{ matrix.name }} - notify: + cleanup: needs: test-tauri - if: always() && needs.test-tauri.result == 'success' + if: always() && (github.event.action == 'opened' || github.event.label.name == '需要 Action 构建') runs-on: ubuntu-latest permissions: pull-requests: write @@ -110,15 +98,52 @@ jobs: - uses: actions/github-script@v7 with: script: | + const results = JSON.parse('${{ toJson(needs.test-tauri.result) }}'); + const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + const commit = context.sha.substring(0, 7); + const branch = context.ref.replace('refs/heads/', ''); + + let body = ''; + + if (results == 'success') { + body = `✅ **构建成功**\n\n`; + body += `- 分支: ${branch}\n`; + body += `- 提交: ${commit}\n`; + body += `- 触发方式: ${context.payload.action == 'opened' ? 'PR 创建' : '标签触发'}\n\n`; + body += `**构建产物:**\n`; + body += `- macOS ARM64: \`tauri-app-macos-arm64\`\n`; + body += `- macOS x64: \`tauri-app-macos-x64\`\n`; + body += `- Linux: \`tauri-app-linux\`\n`; + body += `- Windows: \`tauri-app-windows\`\n\n`; + body += `[查看详情并下载](${runUrl})`; + } else { + body = `❌ **构建失败**\n\n`; + body += `- 分支: ${branch}\n`; + body += `- 提交: ${commit}\n`; + body += `- 触发方式: ${context.payload.action == 'opened' ? 'PR 创建' : '标签触发'}\n`; + body += `- 失败状态: ${results}\n\n`; + body += `请检查以下可能原因:\n`; + body += `- 代码编译错误\n`; + body += `- 依赖安装失败\n`; + body += `- 构建配置问题\n\n`; + body += `[查看详细日志](${runUrl})`; + } + await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `✅ **构建完成**\n\n所有平台构建成功,请在 Actions 页面下载产物。` - }); - await github.rest.issues.removeLabel({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - name: 'Action 构建' + body: body }); + + if (github.event.label.name == '需要 Action 构建') { + try { + await github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: '需要 Action 构建' + }); + } catch (e) { + } + } From 1159b7c22b9c0c85c3ca37301c86721c7cf1541b Mon Sep 17 00:00:00 2001 From: Moralts Date: Sun, 22 Feb 2026 18:04:21 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix(github/action):=20=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=BB=E9=99=A4=E6=A0=87=E7=AD=BE=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2ca7561..503dfef 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -name: 'Tauri App Build Test' +name: 'Tauri App Build PR Test' on: pull_request: