|
| 1 | +name: Native Build (iOS & Android) |
| 2 | + |
| 3 | +# Builds the native static/shared libraries for all supported platforms and |
| 4 | +# ABIs, then uploads the artifacts for use by the MAUI build workflow. |
| 5 | +# |
| 6 | +# Triggered on every push and pull request that touches native code or the |
| 7 | +# build scripts. |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + paths: |
| 12 | + - 'native/**' |
| 13 | + - '.github/workflows/native-build.yml' |
| 14 | + pull_request: |
| 15 | + paths: |
| 16 | + - 'native/**' |
| 17 | + - '.github/workflows/native-build.yml' |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + # ── iOS XCFramework ──────────────────────────────────────────────────────── |
| 24 | + ios: |
| 25 | + name: iOS XCFramework (${{ matrix.platform }}) |
| 26 | + runs-on: macos-15 |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + include: |
| 30 | + - platform: OS64 |
| 31 | + sysroot: iphoneos |
| 32 | + label: device-arm64 |
| 33 | + - platform: SIMULATORARM64 |
| 34 | + sysroot: iphonesimulator |
| 35 | + label: sim-arm64 |
| 36 | + - platform: SIMULATOR64 |
| 37 | + sysroot: iphonesimulator |
| 38 | + label: sim-x86_64 |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Select Xcode |
| 44 | + run: sudo xcode-select --switch /Applications/Xcode_16.2.app |
| 45 | + |
| 46 | + - name: Configure CMake |
| 47 | + run: | |
| 48 | + cmake -S native \ |
| 49 | + -B .build/ios/${{ matrix.label }} \ |
| 50 | + -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/native/cmake/ios.toolchain.cmake" \ |
| 51 | + -DPLATFORM=${{ matrix.platform }} \ |
| 52 | + -DDEPLOYMENT_TARGET=15.0 \ |
| 53 | + -DCMAKE_BUILD_TYPE=Release \ |
| 54 | + -GXcode |
| 55 | +
|
| 56 | + - name: Build |
| 57 | + run: | |
| 58 | + cmake --build .build/ios/${{ matrix.label }} \ |
| 59 | + --config Release \ |
| 60 | + --target ferrum_test_stub |
| 61 | +
|
| 62 | + - name: Upload slice artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: ios-${{ matrix.label }} |
| 66 | + path: .build/ios/${{ matrix.label }}/Release-${{ matrix.sysroot }}/libferrum_test_stub.a |
| 67 | + |
| 68 | + # Assemble the full XCFramework from the three slices |
| 69 | + ios-xcframework: |
| 70 | + name: Assemble XCFramework |
| 71 | + runs-on: macos-15 |
| 72 | + needs: ios |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - uses: actions/download-artifact@v4 |
| 77 | + with: |
| 78 | + name: ios-device-arm64 |
| 79 | + path: .slices/device |
| 80 | + |
| 81 | + - uses: actions/download-artifact@v4 |
| 82 | + with: |
| 83 | + name: ios-sim-arm64 |
| 84 | + path: .slices/sim-arm64 |
| 85 | + |
| 86 | + - uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + name: ios-sim-x86_64 |
| 89 | + path: .slices/sim-x86_64 |
| 90 | + |
| 91 | + - name: Create fat simulator library |
| 92 | + run: | |
| 93 | + lipo -create \ |
| 94 | + .slices/sim-arm64/libferrum_test_stub.a \ |
| 95 | + .slices/sim-x86_64/libferrum_test_stub.a \ |
| 96 | + -output .slices/sim-fat/libferrum_test_stub.a |
| 97 | +
|
| 98 | + - name: Create XCFramework |
| 99 | + run: | |
| 100 | + mkdir -p artifacts/ios |
| 101 | + xcodebuild -create-xcframework \ |
| 102 | + -library .slices/device/libferrum_test_stub.a \ |
| 103 | + -library .slices/sim-fat/libferrum_test_stub.a \ |
| 104 | + -output artifacts/ios/libferrum_test_stub.xcframework |
| 105 | +
|
| 106 | + - name: Upload XCFramework |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: ios-xcframework |
| 110 | + path: artifacts/ios/libferrum_test_stub.xcframework |
| 111 | + |
| 112 | + # ── Android .so per ABI ──────────────────────────────────────────────────── |
| 113 | + android: |
| 114 | + name: Android (${{ matrix.abi }}) |
| 115 | + runs-on: ubuntu-24.04 |
| 116 | + strategy: |
| 117 | + matrix: |
| 118 | + abi: [arm64-v8a, armeabi-v7a, x86_64, x86] |
| 119 | + |
| 120 | + steps: |
| 121 | + - uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Set up NDK |
| 124 | + uses: android-actions/setup-android@v3 |
| 125 | + |
| 126 | + - name: Install NDK |
| 127 | + run: sdkmanager "ndk;27.2.12479018" |
| 128 | + |
| 129 | + - name: Configure CMake |
| 130 | + run: | |
| 131 | + NDK_ROOT="${ANDROID_SDK_ROOT}/ndk/27.2.12479018" |
| 132 | + cmake -S native \ |
| 133 | + -B .build/android/${{ matrix.abi }} \ |
| 134 | + -DCMAKE_TOOLCHAIN_FILE="${NDK_ROOT}/build/cmake/android.toolchain.cmake" \ |
| 135 | + -DANDROID_ABI=${{ matrix.abi }} \ |
| 136 | + -DANDROID_PLATFORM=android-24 \ |
| 137 | + -DCMAKE_BUILD_TYPE=Release |
| 138 | +
|
| 139 | + - name: Build |
| 140 | + run: | |
| 141 | + cmake --build .build/android/${{ matrix.abi }} \ |
| 142 | + --config Release \ |
| 143 | + --target ferrum_test_stub |
| 144 | +
|
| 145 | + - name: Upload .so artifact |
| 146 | + uses: actions/upload-artifact@v4 |
| 147 | + with: |
| 148 | + name: android-${{ matrix.abi }} |
| 149 | + path: .build/android/${{ matrix.abi }}/libferrum_test_stub.so |
0 commit comments