⬆️ 升级项目依赖 #1244
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- main | |
pull_request_target: | |
paths: | |
- "src/**" | |
- "src-tauri/src/**" | |
- "tests/**" | |
- "package.json" | |
- "vite.config.ts" | |
- "src-tauri/Cargo.toml" | |
- "src-tauri/tauri.conf.json" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
label: linux-amd64 | |
target: x86_64-unknown-linux-gnu | |
- os: macos-latest | |
label: macos-amd64 | |
target: x86_64-apple-darwin | |
- os: macos-latest | |
label: macos-arm64 | |
target: aarch64-apple-darwin | |
- os: windows-latest | |
label: windows-amd64 | |
target: x86_64-pc-windows-msvc | |
name: ${{ matrix.label }} | |
runs-on: ${{ matrix.os }} | |
env: | |
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} | |
GITHUB_BUILD_SHA: ${{ github.event.pull_request && github.event.pull_request.head.sha || github.sha }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies (ubuntu only) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | |
- name: Rust setup | |
uses: dtolnay/rust-toolchain@stable | |
- name: Rust cache | |
uses: swatinem/rust-cache@v2 | |
with: | |
workspaces: ./src-tauri -> target | |
- name: Pnpm setup | |
uses: pnpm/action-setup@v4 | |
- name: Sync node version and setup cache | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
cache: pnpm | |
- name: Install app dependencies | |
run: pnpm install | |
- name: Rustup add target | |
run: rustup target add ${{ matrix.target }} | |
- name: Build the app | |
id: tauri-build | |
uses: tauri-apps/tauri-action@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
args: -t ${{ matrix.target }} -c '{"bundle":{"createUpdaterArtifacts":false}}' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: 'matcha_${{steps.tauri-build.outputs.appVersion}}_${{ matrix.label }}' | |
path: "${{ join(fromJSON(steps.tauri-build.outputs.artifactPaths), '\n') }}" | |
comment: | |
needs: build | |
permissions: | |
pull-requests: write | |
if: github.event.pull_request && github.event.sender.type != 'Bot' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Format artifact comment | |
id: format-artifact-comment | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.runId | |
}); | |
const createArtifactComment = (await import(`${{github.workspace}}/scripts/formatArtifactComment.js`)).default; | |
return createArtifactComment(artifacts.data.artifacts, '${{github.event.pull_request.head.sha}}'); | |
- name: Add artifact comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
number: ${{ github.event.pull_request.number }} | |
header: artifacts | |
message: ${{ steps.format-artifact-comment.outputs.result }} |