diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.yml index 20885b4..dc0b5ed 100644 --- a/.github/workflows/build-desktop.yml +++ b/.github/workflows/build-desktop.yml @@ -45,44 +45,65 @@ jobs: target: x86_64-pc-windows-msvc binary: mcp-feedback-enhanced-desktop.exe name: windows - enabled: ${{ github.event.inputs.platforms == 'all' || github.event.inputs.platforms == 'windows' || github.event.inputs.platforms == '' }} - os: macos-latest target: x86_64-apple-darwin binary: mcp-feedback-enhanced-desktop name: macos-intel - enabled: ${{ github.event.inputs.platforms == 'all' || github.event.inputs.platforms == 'macos' || github.event.inputs.platforms == '' }} - os: macos-latest target: aarch64-apple-darwin binary: mcp-feedback-enhanced-desktop name: macos-arm64 - enabled: ${{ github.event.inputs.platforms == 'all' || github.event.inputs.platforms == 'macos' || github.event.inputs.platforms == '' }} - os: ubuntu-latest target: x86_64-unknown-linux-gnu binary: mcp-feedback-enhanced-desktop name: linux - enabled: ${{ github.event.inputs.platforms == 'all' || github.event.inputs.platforms == 'linux' || github.event.inputs.platforms == '' }} runs-on: ${{ matrix.os }} - if: ${{ matrix.enabled != 'false' }} steps: + - name: Check if platform should be built + id: check_platform + run: | + SHOULD_BUILD="false" + PLATFORM_INPUT="${{ github.event.inputs.platforms }}" + MATRIX_NAME="${{ matrix.name }}" + + # 檢查是否應該構建此平台 + if [ "$PLATFORM_INPUT" = "all" ] || [ "$PLATFORM_INPUT" = "" ]; then + SHOULD_BUILD="true" + elif [ "$PLATFORM_INPUT" = "windows" ] && [ "$MATRIX_NAME" = "windows" ]; then + SHOULD_BUILD="true" + elif [ "$PLATFORM_INPUT" = "macos" ] && ([ "$MATRIX_NAME" = "macos-intel" ] || [ "$MATRIX_NAME" = "macos-arm64" ]); then + SHOULD_BUILD="true" + elif [ "$PLATFORM_INPUT" = "linux" ] && [ "$MATRIX_NAME" = "linux" ]; then + SHOULD_BUILD="true" + fi + + echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT + echo "Platform: $MATRIX_NAME, Input: $PLATFORM_INPUT, Should build: $SHOULD_BUILD" + - name: Checkout code + if: steps.check_platform.outputs.should_build == 'true' uses: actions/checkout@v4 - name: Install Rust + if: steps.check_platform.outputs.should_build == 'true' uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - name: Install uv + if: steps.check_platform.outputs.should_build == 'true' uses: astral-sh/setup-uv@v4 with: version: "latest" - name: Set up Python + if: steps.check_platform.outputs.should_build == 'true' run: uv python install - name: Install dependencies + if: steps.check_platform.outputs.should_build == 'true' run: uv sync --dev - name: Cache Rust dependencies @@ -98,7 +119,7 @@ jobs: ${{ runner.os }}-cargo- - name: Install platform-specific dependencies (Linux) - if: matrix.os == 'ubuntu-latest' + if: ${{ steps.check_platform.outputs.should_build == 'true' && matrix.os == 'ubuntu-latest' }} run: | sudo apt-get update sudo apt-get install -y \ @@ -110,6 +131,7 @@ jobs: libayatana-appindicator3-dev - name: Build desktop application for ${{ matrix.name }} + if: steps.check_platform.outputs.should_build == 'true' run: | cd src-tauri echo "🔨 開始構建 ${{ matrix.name }} (${{ matrix.target }})..." @@ -117,6 +139,7 @@ jobs: echo "✅ 構建完成" - name: Verify build output + if: steps.check_platform.outputs.should_build == 'true' run: | echo "🔍 檢查構建產物..." BINARY_PATH="src-tauri/target/${{ matrix.target }}/release/${{ matrix.binary }}" @@ -142,7 +165,7 @@ jobs: shell: bash - name: Upload desktop binary - if: ${{ github.event.inputs.upload_artifacts != 'false' }} + if: ${{ steps.check_platform.outputs.should_build == 'true' && github.event.inputs.upload_artifacts != 'false' }} uses: actions/upload-artifact@v4 with: name: desktop-${{ matrix.name }}