Skip to content

Commit

Permalink
Use flutter & java action for build workflow
Browse files Browse the repository at this point in the history
- Build for Windows
- Build on x86_64 and ARM64 versions macOS
  • Loading branch information
PeteClubSeven committed Feb 9, 2024
1 parent 408e1fa commit b7c9a22
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 40 deletions.
57 changes: 19 additions & 38 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,40 @@ jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
flutter: ["3.7.12", "3.16.7"] # Flutter 3.7.12 is to maintain Breez support
runs-on: ${{matrix.os}}
env:
FLUTTER_VERSION: ${{ matrix.flutter }}
os: [macos-latest, ubuntu-latest, windows-latest] # macOS 12 is x86_64 and macOS 14 is ARM64
flutter: ['3.7.12', '3.16.5', 'any'] # Flutter 3.7.12 is to maintain Breez support
include:
- os: macos-14
flutter: '3.7.12'
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.channel == 'any' }}
steps:
- uses: actions/checkout@v4

- name: Set up Java
run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> "$GITHUB_ENV"

- id: cache-deps
uses: actions/cache@v3
- uses: actions/setup-java@v4
with:
key: ${{ matrix.os }}-build-${{ matrix.flutter }}-${{ hashFiles('**/pubspec.yaml', '**/pubspec.lock') }}
path: |
.deps
- if: steps.cache-deps.outputs.cache-hit != 'true' && matrix.os == 'macos-latest'
name: Download & extract Flutter (Mac)
run: |
mkdir -p .deps
curl -o flutter.zip https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_$FLUTTER_VERSION-stable.zip
unzip flutter.zip -d .deps/
- if: steps.cache-deps.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest'
name: Download & extract Flutter (Linux)
run: |
mkdir -p .deps
curl -o flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_$FLUTTER_VERSION-stable.tar.xz
tar -C .deps/ -xvf flutter.tar.xz
distribution: 'zulu'
java-version: '17'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.flutter }}

- if: matrix.os == 'macos-latest'
name: Install tap-protocol dependencies (Mac)
run: brew install cmake coreutils
- if: startsWith(matrix.os, 'macos-12')
name: Install dependencies (macOS 12)
run: brew install coreutils

- name: Set up Flutter
run: |
export PATH="$(pwd)/.deps/flutter/bin:$PATH"
export PUB_CACHE="$(pwd)/.deps/pub_cache"
flutter config --no-analytics
flutter doctor
flutter doctor -v
flutter pub get
echo "PATH=$PATH" >> "$GITHUB_ENV"
echo "PUB_CACHE=$PUB_CACHE" >> "$GITHUB_ENV"
- if: matrix.os == 'macos-latest'
- if: startsWith(matrix.os, 'macos')
name: Build iOS frameworks
run: |
cd example
flutter build ios-framework
- if: matrix.os == 'macos-latest'
- if: startsWith(matrix.os, 'macos')
name: Build iOS example
run: |
cd example
Expand Down
8 changes: 8 additions & 0 deletions scripts/update_submodules.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SET scriptDir=%~dp0
SET rootDir="%scriptDir%\.."

IF EXIST "%rootDir%\.git" IF EXIST "%rootDir%\.git\HEAD" (
PUSHD "%rootDir%"
git submodule update --init --recursive
POPD
)
4 changes: 2 additions & 2 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ target_compile_definitions(cktap_protocol PRIVATE "CKTAP_PLATFORM_${CMAKE_SYSTEM

# Flutter by default doesn't initialize submodules for plugins. We must make
# sure tap-protocol is available
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "WINDOWS")
# TODO: Add Windows command
if(CMAKE_HOST_WIN32)
execute_process(COMMAND cmd.exe /c "${PROJECT_SOURCE_DIR}\\..\\..\\scripts\\update_submodules.bat")
else()
execute_process(COMMAND "${PROJECT_SOURCE_DIR}/../../scripts/update_submodules.sh")
endif()
Expand Down

0 comments on commit b7c9a22

Please sign in to comment.