Skip to content

Commit 7088248

Browse files
committed
Refactor CI workflow for platform-specific builds
Split the build job into separate jobs for Android, iOS, Linux, macOS, Windows, and OpenHarmony platforms. Each job now configures and builds examples for its respective platform, improving clarity and maintainability of the CI workflow. The OpenHarmony job is prepared but disabled until the SDK is available in CI.
1 parent f8a5f9f commit 7088248

File tree

1 file changed

+175
-29
lines changed

1 file changed

+175
-29
lines changed

.github/workflows/build.yml

Lines changed: 175 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,99 @@ on:
77
branches: [main]
88

99
jobs:
10-
build:
10+
# Android builds (ARM64, ARMv7, x86_64)
11+
build-android:
12+
strategy:
13+
matrix:
14+
abi:
15+
- arm64-v8a
16+
- armeabi-v7a
17+
- x86_64
18+
19+
runs-on: ubuntu-latest
20+
name: Build Android (${{ matrix.abi }})
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up JDK
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: "temurin"
29+
java-version: "17"
30+
31+
- name: Install Android NDK
32+
run: |
33+
ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
34+
SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
35+
echo "y" | $SDKMANAGER "ndk;25.2.9519653"
36+
echo "ANDROID_NDK_HOME=${ANDROID_SDK_ROOT}/ndk/25.2.9519653" >> $GITHUB_ENV
37+
echo "ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk/25.2.9519653" >> $GITHUB_ENV
38+
39+
- name: Install dependencies
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y ninja-build
43+
44+
- name: Configure CMake for Android
45+
shell: bash
46+
run: |
47+
mkdir build-android
48+
cd build-android
49+
cmake .. \
50+
-DCMAKE_SYSTEM_NAME=Android \
51+
-DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT \
52+
-DCMAKE_ANDROID_ARCH_ABI=${{ matrix.abi }} \
53+
-DCMAKE_BUILD_TYPE=Release
54+
55+
- name: Build Examples
56+
shell: bash
57+
run: |
58+
cd build-android
59+
cmake --build . --config Release
60+
61+
# iOS builds (device and simulator)
62+
build-ios:
1163
strategy:
1264
matrix:
13-
os:
14-
- macos-latest
15-
- ubuntu-latest
16-
- windows-latest
1765
include:
18-
- os: macos-latest
19-
platform: macos
20-
- os: ubuntu-latest
21-
platform: linux
22-
- os: windows-latest
23-
platform: windows
66+
- target: device
67+
arch: arm64
68+
sysroot: iphoneos
69+
platform_name: iOS Device
70+
- target: simulator
71+
arch: arm64
72+
sysroot: iphonesimulator
73+
platform_name: iOS Simulator
74+
75+
runs-on: macos-latest
76+
name: Build ${{ matrix.platform_name }}
2477

25-
runs-on: ${{ matrix.os }}
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Configure CMake for iOS
82+
shell: bash
83+
run: |
84+
mkdir build-ios-${{ matrix.target }}
85+
cd build-ios-${{ matrix.target }}
86+
cmake .. \
87+
-DCMAKE_SYSTEM_NAME=iOS \
88+
-DCMAKE_SYSTEM_VERSION=14.0 \
89+
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
90+
-DCMAKE_OSX_SYSROOT=${{ matrix.sysroot }} \
91+
-DCMAKE_BUILD_TYPE=Release
92+
93+
- name: Build Examples
94+
shell: bash
95+
run: |
96+
cd build-ios-${{ matrix.target }}
97+
cmake --build . --config Release
98+
99+
# Linux build
100+
build-linux:
101+
runs-on: ubuntu-latest
102+
name: Build Linux
26103

27104
steps:
28105
- uses: actions/checkout@v4
@@ -31,33 +108,102 @@ jobs:
31108
shell: bash
32109
run: |
33110
cmake --version
34-
if [ "${{ matrix.platform }}" = "linux" ]; then
35-
sudo apt-get update
36-
sudo apt-get install -y ninja-build libgtk-3-dev libx11-dev libxi-dev libayatana-appindicator3-dev
37-
fi
111+
sudo apt-get update
112+
sudo apt-get install -y ninja-build libgtk-3-dev libx11-dev libxi-dev libayatana-appindicator3-dev
38113
39114
- name: Configure CMake
40115
shell: bash
41116
run: |
42117
mkdir build
43118
cd build
44-
if [ "${{ matrix.platform }}" = "windows" ]; then
45-
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022"
46-
else
47-
cmake .. -DCMAKE_BUILD_TYPE=Release
48-
fi
119+
cmake .. -DCMAKE_BUILD_TYPE=Release
49120
50121
- name: Build Examples
51122
shell: bash
52123
run: |
53124
cd build
54125
cmake --build . --config Release
55126
56-
# - name: Upload artifacts
57-
# uses: actions/upload-artifact@v4
58-
# with:
59-
# name: examples-${{ matrix.platform }}
60-
# path: |
61-
# build/examples/*/
62-
# !build/examples/*/CMakeFiles/
63-
# !build/examples/*/cmake_install.cmake
127+
# macOS build
128+
build-macos:
129+
runs-on: macos-latest
130+
name: Build macOS
131+
132+
steps:
133+
- uses: actions/checkout@v4
134+
135+
- name: Set up CMake
136+
shell: bash
137+
run: cmake --version
138+
139+
- name: Configure CMake
140+
shell: bash
141+
run: |
142+
mkdir build
143+
cd build
144+
cmake .. -DCMAKE_BUILD_TYPE=Release
145+
146+
- name: Build Examples
147+
shell: bash
148+
run: |
149+
cd build
150+
cmake --build . --config Release
151+
152+
# OpenHarmony builds
153+
# Note: OpenHarmony requires SDK which is not readily available in CI
154+
# This job is prepared but will be skipped by default
155+
build-openharmony:
156+
runs-on: ubuntu-latest
157+
name: Build OpenHarmony
158+
if: false # Disabled until OpenHarmony SDK toolchain is available in CI
159+
160+
steps:
161+
- uses: actions/checkout@v4
162+
163+
- name: Install dependencies
164+
run: |
165+
sudo apt-get update
166+
sudo apt-get install -y ninja-build
167+
168+
- name: Configure CMake for OpenHarmony
169+
shell: bash
170+
run: |
171+
# OpenHarmony SDK path would need to be set here
172+
# export OHOS_SDK_PATH=/path/to/openharmony/sdk
173+
mkdir build-openharmony
174+
cd build-openharmony
175+
cmake .. \
176+
-DCMAKE_SYSTEM_NAME=OHOS \
177+
-DCMAKE_TOOLCHAIN_FILE=$OHOS_SDK_PATH/native/build/cmake/ohos.toolchain.cmake \
178+
-DCMAKE_BUILD_TYPE=Release
179+
180+
- name: Build Examples
181+
shell: bash
182+
run: |
183+
cd build-openharmony
184+
cmake --build . --config Release
185+
186+
# Windows build
187+
build-windows:
188+
runs-on: windows-latest
189+
name: Build Windows
190+
191+
steps:
192+
- uses: actions/checkout@v4
193+
194+
- name: Set up CMake
195+
shell: bash
196+
run: cmake --version
197+
198+
- name: Configure CMake
199+
shell: bash
200+
run: |
201+
mkdir build
202+
cd build
203+
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022"
204+
205+
- name: Build Examples
206+
shell: bash
207+
run: |
208+
cd build
209+
cmake --build . --config Release

0 commit comments

Comments
 (0)