Skip to content

Commit 9178438

Browse files
committed
Refactor CI workflow to split platform builds
The CI workflow is restructured to separate build jobs for Android, iOS, Linux, macOS, and Windows, each with platform-specific steps and matrix strategies. This improves clarity, parallelism, and maintainability of platform builds, and adds explicit support for multiple Android ABIs and iOS targets.
1 parent 8695cf6 commit 9178438

File tree

1 file changed

+169
-52
lines changed

1 file changed

+169
-52
lines changed

.github/workflows/ci.yml

Lines changed: 169 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,25 @@ jobs:
8484
- name: Run tests
8585
run: dart pub global run melos run test
8686

87-
build:
88-
name: Build (${{ matrix.os }})
89-
runs-on: ${{ matrix.os }}
87+
# Android builds (ARM64, ARMv7, x86_64)
88+
build-android:
89+
name: Build Android (${{ matrix.abi }})
90+
runs-on: ubuntu-latest
9091
needs: [lint]
9192
strategy:
9293
fail-fast: false
9394
matrix:
94-
os: [ubuntu-latest, macos-latest, windows-latest]
95+
abi:
96+
- arm64-v8a
97+
- armeabi-v7a
98+
- x86_64
9599

96100
steps:
97101
- name: Checkout repository
98102
uses: actions/checkout@v4
99103
with:
100104
submodules: recursive
101-
105+
102106
- name: Setup Flutter
103107
uses: subosito/flutter-action@v2
104108
with:
@@ -110,26 +114,112 @@ jobs:
110114
run: dart pub global activate melos
111115

112116
- name: Add melos to PATH
113-
shell: bash
114-
run: |
115-
if [[ "$RUNNER_OS" == "Windows" ]]; then
116-
echo "$USERPROFILE/.pub-cache/bin" >> $GITHUB_PATH
117-
else
118-
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
119-
fi
117+
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
120118

121119
- name: Bootstrap melos
122120
run: dart pub global run melos bootstrap
123121

124-
- name: Setup Java for Android
125-
if: matrix.os == 'ubuntu-latest'
122+
- name: Setup Java
126123
uses: actions/setup-java@v4
127124
with:
128125
distribution: 'temurin'
129126
java-version: '17'
130127

128+
- name: Build cnativeapi example Android (${{ matrix.abi }})
129+
run: |
130+
cd packages/cnativeapi/example
131+
flutter build apk --release --target-platform android-${{ matrix.abi }}
132+
133+
- name: Build nativeapi example Android (${{ matrix.abi }})
134+
run: |
135+
cd packages/nativeapi/example
136+
flutter build apk --release --target-platform android-${{ matrix.abi }}
137+
138+
# iOS builds (device and simulator)
139+
build-ios:
140+
name: Build iOS (${{ matrix.target }})
141+
runs-on: macos-latest
142+
needs: [lint]
143+
strategy:
144+
fail-fast: false
145+
matrix:
146+
include:
147+
- target: device
148+
sdk: iphoneos
149+
platform_name: iOS Device
150+
- target: simulator
151+
sdk: iphonesimulator
152+
platform_name: iOS Simulator
153+
154+
steps:
155+
- name: Checkout repository
156+
uses: actions/checkout@v4
157+
with:
158+
submodules: recursive
159+
160+
- name: Setup Flutter
161+
uses: subosito/flutter-action@v2
162+
with:
163+
flutter-version: '3.38.7'
164+
channel: 'stable'
165+
cache: true
166+
167+
- name: Install melos
168+
run: dart pub global activate melos
169+
170+
- name: Add melos to PATH
171+
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
172+
173+
- name: Bootstrap melos
174+
run: dart pub global run melos bootstrap
175+
176+
- name: Build cnativeapi example iOS (${{ matrix.target }})
177+
run: |
178+
cd packages/cnativeapi/example
179+
if [ "${{ matrix.target }}" == "simulator" ]; then
180+
flutter build ios --simulator --release --no-codesign
181+
else
182+
flutter build ios --release --no-codesign
183+
fi
184+
185+
- name: Build nativeapi example iOS (${{ matrix.target }})
186+
run: |
187+
cd packages/nativeapi/example
188+
if [ "${{ matrix.target }}" == "simulator" ]; then
189+
flutter build ios --simulator --release --no-codesign
190+
else
191+
flutter build ios --release --no-codesign
192+
fi
193+
194+
# Linux build
195+
build-linux:
196+
name: Build Linux
197+
runs-on: ubuntu-latest
198+
needs: [lint]
199+
200+
steps:
201+
- name: Checkout repository
202+
uses: actions/checkout@v4
203+
with:
204+
submodules: recursive
205+
206+
- name: Setup Flutter
207+
uses: subosito/flutter-action@v2
208+
with:
209+
flutter-version: '3.38.7'
210+
channel: 'stable'
211+
cache: true
212+
213+
- name: Install melos
214+
run: dart pub global activate melos
215+
216+
- name: Add melos to PATH
217+
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
218+
219+
- name: Bootstrap melos
220+
run: dart pub global run melos bootstrap
221+
131222
- name: Install Linux dependencies
132-
if: matrix.os == 'ubuntu-latest'
133223
run: |
134224
sudo apt-get update
135225
sudo apt-get install -y \
@@ -142,62 +232,89 @@ jobs:
142232
clang \
143233
libayatana-appindicator3-dev
144234
145-
- name: Build cnativeapi example Android
146-
if: matrix.os == 'ubuntu-latest'
147-
run: |
148-
cd packages/cnativeapi/example
149-
flutter build apk --release
150-
151-
- name: Build cnativeapi example iOS
152-
if: matrix.os == 'macos-latest'
235+
- name: Build cnativeapi example Linux
153236
run: |
154237
cd packages/cnativeapi/example
155-
flutter build ios --release --no-codesign
238+
flutter build linux --release
156239
157-
- name: Build cnativeapi example Linux
158-
if: matrix.os == 'ubuntu-latest'
240+
- name: Build nativeapi example Linux
159241
run: |
160-
cd packages/cnativeapi/example
242+
cd packages/nativeapi/example
161243
flutter build linux --release
244+
245+
# macOS build
246+
build-macos:
247+
name: Build macOS
248+
runs-on: macos-latest
249+
needs: [lint]
250+
251+
steps:
252+
- name: Checkout repository
253+
uses: actions/checkout@v4
254+
with:
255+
submodules: recursive
256+
257+
- name: Setup Flutter
258+
uses: subosito/flutter-action@v2
259+
with:
260+
flutter-version: '3.38.7'
261+
channel: 'stable'
262+
cache: true
263+
264+
- name: Install melos
265+
run: dart pub global activate melos
266+
267+
- name: Add melos to PATH
268+
run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
269+
270+
- name: Bootstrap melos
271+
run: dart pub global run melos bootstrap
162272

163273
- name: Build cnativeapi example macOS
164-
if: matrix.os == 'macos-latest'
165274
run: |
166275
cd packages/cnativeapi/example
167276
flutter build macos --release
168277
169-
- name: Build cnativeapi example Windows
170-
if: matrix.os == 'windows-latest'
171-
run: |
172-
cd packages/cnativeapi/example
173-
flutter build windows --release
174-
175-
- name: Build nativeapi example Android
176-
if: matrix.os == 'ubuntu-latest'
278+
- name: Build nativeapi example macOS
177279
run: |
178280
cd packages/nativeapi/example
179-
flutter build apk --release
281+
flutter build macos --release
282+
283+
# Windows build
284+
build-windows:
285+
name: Build Windows
286+
runs-on: windows-latest
287+
needs: [lint]
288+
289+
steps:
290+
- name: Checkout repository
291+
uses: actions/checkout@v4
292+
with:
293+
submodules: recursive
180294

181-
- name: Build nativeapi example iOS
182-
if: matrix.os == 'macos-latest'
183-
run: |
184-
cd packages/nativeapi/example
185-
flutter build ios --release --no-codesign
295+
- name: Setup Flutter
296+
uses: subosito/flutter-action@v2
297+
with:
298+
flutter-version: '3.38.7'
299+
channel: 'stable'
300+
cache: true
186301

187-
- name: Build nativeapi example Linux
188-
if: matrix.os == 'ubuntu-latest'
189-
run: |
190-
cd packages/nativeapi/example
191-
flutter build linux --release
302+
- name: Install melos
303+
run: dart pub global activate melos
304+
305+
- name: Add melos to PATH
306+
shell: bash
307+
run: echo "$USERPROFILE/.pub-cache/bin" >> $GITHUB_PATH
308+
309+
- name: Bootstrap melos
310+
run: dart pub global run melos bootstrap
192311

193-
- name: Build nativeapi example macOS
194-
if: matrix.os == 'macos-latest'
312+
- name: Build cnativeapi example Windows
195313
run: |
196-
cd packages/nativeapi/example
197-
flutter build macos --release
314+
cd packages/cnativeapi/example
315+
flutter build windows --release
198316
199317
- name: Build nativeapi example Windows
200-
if: matrix.os == 'windows-latest'
201318
run: |
202319
cd packages/nativeapi/example
203320
flutter build windows --release

0 commit comments

Comments
 (0)