refactor(certain settings): migrate zustand's async logic to react-qu… #231
This file contains hidden or 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 & Test Common | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| rust_target: x86_64-unknown-linux-gnu | |
| - os: ubuntu-22.04-arm | |
| rust_target: aarch64-unknown-linux-gnu | |
| - os: windows-latest | |
| rust_target: x86_64-pc-windows-msvc | |
| - os: windows-latest | |
| rust_target: aarch64-pc-windows-msvc | |
| # 主仓库可以访问 TAURI_KEY environment,fork PR 访问不到但不会失败 | |
| environment: ${{ (github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request') && 'TAURI_KEY' || '' }} | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Get pnpm store directory | |
| if: runner.os == 'Windows' | |
| id: pnpm-store | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.rust_target }} | |
| - name: Rust cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| workspaces: "./src-tauri -> target" | |
| shared-key: ${{ matrix.rust_target }} | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Get version | |
| id: get_version | |
| shell: bash | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version is $VERSION" | |
| - name: Compute short target name | |
| id: short | |
| shell: bash | |
| run: | | |
| case "${{ matrix.rust_target }}" in | |
| *x86_64-pc-windows*) SHORT=win_x64 ;; | |
| *aarch64-pc-windows*) SHORT=win_arm64 ;; | |
| *x86_64-unknown-linux-gnu*) SHORT=linux_x64 ;; | |
| *aarch64-unknown-linux-gnu*) SHORT=linux_arm64 ;; | |
| *) SHORT=unknown ;; | |
| esac | |
| echo "SHORT=$SHORT" >> $GITHUB_OUTPUT | |
| # Linux 专用:使用官方 Action 安装最新版 mold | |
| # 这比 apt-get 安装的旧版本快且稳,而且会自动配置相关环境 | |
| - name: Install Mold (Linux) | |
| if: runner.os == 'Linux' | |
| uses: rui314/setup-mold@v1 | |
| # Linux 依赖安装 (去掉了 mold,因为上一步已经安装) | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgtk-3-dev libsoup-3.0-dev libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf clang | |
| # 配置链接器 (核心逻辑) | |
| - name: Configure Rust linker | |
| shell: bash | |
| run: | | |
| mkdir -p .cargo | |
| # === Linux 配置 === | |
| if [[ "${{ matrix.os }}" == "ubuntu-22.04" ]] || [[ "${{ matrix.os }}" == "ubuntu-22.04-arm" ]]; then | |
| echo "Configuring mold for Linux..." | |
| cat >> .cargo/config.toml <<EOF | |
| [target.x86_64-unknown-linux-gnu] | |
| linker = "clang" | |
| rustflags = ["-C", "link-arg=-fuse-ld=mold"] | |
| EOF | |
| # === Windows 配置 === | |
| elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then | |
| echo "Configuring lld for Windows..." | |
| cat >> .cargo/config.toml <<EOF | |
| [target.x86_64-pc-windows-msvc] | |
| linker = "lld-link" | |
| [target.aarch64-pc-windows-msvc] | |
| linker = "lld-link" | |
| EOF | |
| fi | |
| # Fork PR:禁用 updater artifacts 以支持无私钥构建 | |
| - name: Disable updater artifacts for fork PR | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository | |
| shell: bash | |
| run: | | |
| echo "🔍 Detected fork PR, disabling updater artifacts..." | |
| node -e " | |
| const fs = require('fs'); | |
| const path = './src-tauri/tauri.conf.json'; | |
| const config = JSON.parse(fs.readFileSync(path, 'utf8')); | |
| if (config.bundle) { | |
| config.bundle.createUpdaterArtifacts = false; | |
| console.log('✅ Disabled updater artifacts - build will succeed without signing keys'); | |
| } | |
| fs.writeFileSync(path, JSON.stringify(config, null, '\t')); | |
| " | |
| - name: Build with Tauri Action | |
| uses: tauri-apps/tauri-action@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} | |
| TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }} | |
| with: | |
| # 不在这里创建 GitHub release,仅构建 | |
| args: --target ${{ matrix.rust_target }} | |
| tagName: "" | |
| releaseName: "" | |
| releaseBody: "" | |
| releaseDraft: false | |
| prerelease: false | |
| includeDebug: false | |
| includeRelease: true | |
| tauriScript: pnpm tauri | |
| # 显示构建状态 | |
| - name: Build status | |
| shell: bash | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then | |
| echo "⚠️ Fork PR: Build completed WITHOUT signing" | |
| echo " The application will work normally but won't support auto-updates" | |
| else | |
| echo "✅ Build completed with signing enabled and auto-update support" | |
| fi | |
| # Upload build artifacts for testings | |
| - name: Upload Executable (Artifact) | |
| if: matrix.os == 'windows-latest' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ReinaManager-${{ steps.get_version.outputs.VERSION }}-${{ steps.short.outputs.SHORT }}-exe | |
| path: src-tauri/target/${{ matrix.rust_target }}/release/ReinaManager.exe | |
| if-no-files-found: warn | |
| - name: Upload MSI Installer (Artifact) | |
| if: matrix.os == 'windows-latest' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ReinaManager-${{ steps.get_version.outputs.VERSION }}-${{ steps.short.outputs.SHORT }}-msi | |
| path: src-tauri/target/${{ matrix.rust_target }}/release/bundle/msi/*.msi | |
| if-no-files-found: warn | |
| - name: Upload NSIS Installer (Artifact) | |
| if: matrix.os == 'windows-latest' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ReinaManager-${{ steps.get_version.outputs.VERSION }}-${{ steps.short.outputs.SHORT }}-setup | |
| path: src-tauri/target/${{ matrix.rust_target }}/release/bundle/nsis/*.exe | |
| if-no-files-found: warn | |
| - name: Upload deb (Artifact) | |
| if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-22.04-arm' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ReinaManager-${{ steps.get_version.outputs.VERSION }}-${{ steps.short.outputs.SHORT }}-deb | |
| path: src-tauri/target/${{ matrix.rust_target }}/release/bundle/deb/*.deb | |
| if-no-files-found: warn | |
| - name: Upload rpm (Artifact) | |
| if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-22.04-arm' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ReinaManager-${{ steps.get_version.outputs.VERSION }}-${{ steps.short.outputs.SHORT }}-rpm | |
| path: src-tauri/target/${{ matrix.rust_target }}/release/bundle/rpm/*.rpm | |
| if-no-files-found: warn | |
| - name: Upload AppImage (Artifact) | |
| if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-22.04-arm' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ReinaManager-${{ steps.get_version.outputs.VERSION }}-${{ steps.short.outputs.SHORT }}-appimage | |
| path: src-tauri/target/${{ matrix.rust_target }}/release/bundle/appimage/*.AppImage | |
| if-no-files-found: warn |