From 95b9383ffc564515fa5726faf936f446163e0e6a Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Tue, 15 Oct 2024 15:25:20 +0800 Subject: [PATCH] Fix build failure on macOS due to missing Homebrew --- .github/workflows/build-and-release.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 08b8503..06b5aea 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -41,7 +41,7 @@ jobs: - platform: android arch: arm64 - runs-on: ${{ matrix.platform == 'macos' && matrix.arch == 'arm64' && 'macos-latest' || (matrix.platform == 'ios' && 'macos-latest' || 'ubuntu-latest') }} + runs-on: ${{ matrix.platform == 'macos' && (matrix.arch == 'arm64' ? 'macos-latest' : 'macos-latest') || (matrix.platform == 'ios' && 'macos-latest' || 'ubuntu-latest') }} env: PLATFORM: ${{ matrix.platform }} @@ -64,7 +64,20 @@ jobs: - name: Set up Flutter environment for macOS if: ${{ matrix.platform == 'macos' || matrix.platform == 'ios' }} run: | + # Install Homebrew + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + # Set Homebrew path based on architecture + if [[ "${{ matrix.arch }}" == "arm64" ]]; then + eval "$(/opt/homebrew/bin/brew shellenv)" # For Apple Silicon + else + eval "$(/usr/local/bin/brew shellenv)" # For Intel + fi + + # Install Flutter brew install --cask flutter + + # Set PATH and check Flutter installation export PATH="$PATH:/Users/runner/Library/Flutter/bin" flutter doctor