Skip to content

Commit e0ff02b

Browse files
authored
Merge pull request #329 from patrickkabwe/chore/ci-refactor-templates-android-ios-20250829-211326
chore(ci): refactor template android/ios workflows
2 parents ab7727b + ebc11ea commit e0ff02b

2 files changed

Lines changed: 58 additions & 104 deletions

File tree

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Build Android
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
58
branches:
@@ -25,63 +28,52 @@ on:
2528
- '**/bun.lock'
2629
- '**/react-native.config.js'
2730
- '**/nitro.json'
31+
workflow_dispatch:
2832

2933
concurrency:
3034
group: ${{ github.workflow }}-${{ github.ref }}
3135
cancel-in-progress: true
3236

3337
jobs:
34-
build_new:
35-
name: Build Android Example App (new architecture)
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v4
39-
- uses: oven-sh/setup-bun@v2
40-
41-
- name: Install npm dependencies (bun)
42-
run: bun install
43-
44-
- name: Setup JDK 17
45-
uses: actions/setup-java@v4
46-
with:
47-
distribution: 'zulu'
48-
java-version: 17
49-
java-package: jdk
50-
cache: gradle
51-
52-
- name: Run Gradle Build for example/android/
53-
working-directory: example/android
54-
run: ./gradlew assembleDebug --no-daemon --build-cache
55-
56-
- name: Stop Gradle Daemon
57-
working-directory: example/android
58-
run: ./gradlew --stop
59-
60-
build_old:
61-
name: Build Android Example App (old architecture)
38+
build:
39+
name: Build Android Example App (${{ matrix.arch }})
6240
runs-on: ubuntu-latest
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
arch: [new, old]
6345
steps:
6446
- uses: actions/checkout@v4
6547
- uses: oven-sh/setup-bun@v2
6648

67-
- name: Install npm dependencies (bun)
49+
- name: Install dependencies (bun)
6850
run: bun install
6951

7052
- name: Disable new architecture in gradle.properties
53+
if: matrix.arch == 'old'
7154
run: sed -i "s/newArchEnabled=true/newArchEnabled=false/g" example/android/gradle.properties
7255

7356
- name: Setup JDK 17
74-
uses: actions/setup-java@v4
57+
uses: actions/setup-java@v5
7558
with:
7659
distribution: 'zulu'
77-
java-version: 17
78-
java-package: jdk
79-
cache: gradle
60+
java-version: '17'
61+
cache: 'gradle'
62+
63+
- name: Cache Gradle
64+
uses: actions/cache@v4
65+
with:
66+
path: |
67+
~/.gradle/caches
68+
~/.gradle/wrapper
69+
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/**/*.gradle*') }}
70+
restore-keys: |
71+
${{ runner.os }}-gradle-
8072
81-
- name: Run Gradle Build for example/android/
73+
- name: Run Gradle build
8274
working-directory: example/android
8375
run: ./gradlew assembleDebug --no-daemon --build-cache
8476

85-
- name: Stop Gradle Daemon
77+
- name: Stop Gradle daemon
8678
working-directory: example/android
8779
run: ./gradlew --stop
Lines changed: 31 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Build iOS
22

3+
permissions:
4+
contents: read
5+
36
on:
47
push:
58
branches:
@@ -33,6 +36,7 @@ on:
3336
- '**/*.podspec'
3437
- '**/react-native.config.js'
3538
- '**/nitro.json'
39+
workflow_dispatch:
3640

3741
env:
3842
USE_CCACHE: 1
@@ -42,9 +46,13 @@ concurrency:
4246
cancel-in-progress: true
4347

4448
jobs:
45-
build_new:
46-
name: Build iOS Example App (new architecture)
49+
build:
50+
name: Build iOS Example App (${{ matrix.arch }})
4751
runs-on: macOS-15
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
arch: [new, old]
4856
steps:
4957
- uses: actions/checkout@v4
5058
- uses: oven-sh/setup-bun@v2
@@ -53,93 +61,47 @@ jobs:
5361
with:
5462
xcode-version: 16.4
5563

56-
- name: Install npm dependencies (bun)
57-
run: bun install
58-
59-
- name: Setup Ruby (bundle)
60-
uses: ruby/setup-ruby@v1
61-
with:
62-
ruby-version: 2.7.2
63-
bundler-cache: true
64-
working-directory: example/ios
65-
66-
- name: Install xcpretty
67-
run: gem install xcpretty
68-
69-
- name: Restore Pods cache
70-
uses: actions/cache@v4
71-
with:
72-
path: example/ios/Pods
73-
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }}
74-
restore-keys: |
75-
${{ runner.os }}-pods-
76-
- name: Install Pods
77-
working-directory: example/ios
78-
run: pod install
79-
- name: Build App
80-
working-directory: example/ios
81-
run: "set -o pipefail && xcodebuild \
82-
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
83-
-derivedDataPath build -UseModernBuildSystem=YES \
84-
-workspace $$exampleApp$$.xcworkspace \
85-
-scheme $$exampleApp$$ \
86-
-sdk iphonesimulator \
87-
-configuration Debug \
88-
-destination 'platform=iOS Simulator,name=iPhone 16' \
89-
build \
90-
CODE_SIGNING_ALLOWED=NO | xcpretty"
91-
92-
build_old:
93-
name: Build iOS Example App (old architecture)
94-
runs-on: macOS-15
95-
steps:
96-
- uses: actions/checkout@v4
97-
- uses: oven-sh/setup-bun@v2
98-
99-
- name: Setup Xcode
100-
uses: maxim-lobanov/setup-xcode@v1
101-
with:
102-
xcode-version: 16.4
103-
104-
- name: Install npm dependencies (bun)
64+
- name: Install dependencies (bun)
10565
run: bun install
10666

10767
- name: Disable new architecture in Podfile
68+
if: matrix.arch == 'old'
10869
run: sed -i "" "s/ENV\['RCT_NEW_ARCH_ENABLED'\] = '1'/ENV['RCT_NEW_ARCH_ENABLED'] = '0'/g" example/ios/Podfile
10970

110-
- name: Restore buildcache
111-
uses: mikehardy/buildcache-action@v2
112-
continue-on-error: true
113-
11471
- name: Setup Ruby (bundle)
11572
uses: ruby/setup-ruby@v1
11673
with:
117-
ruby-version: 2.7.2
74+
ruby-version: '3.2'
11875
bundler-cache: true
11976
working-directory: example/ios
12077

12178
- name: Install xcpretty
12279
run: gem install xcpretty
12380

124-
- name: Restore Pods cache
81+
- name: Cache CocoaPods
12582
uses: actions/cache@v4
12683
with:
127-
path: example/ios/Pods
128-
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }}
84+
path: |
85+
~/.cocoapods/repos
86+
example/ios/Pods
87+
key: ${{ runner.os }}-pods-${{ hashFiles('example/ios/Podfile.lock') }}
12988
restore-keys: |
13089
${{ runner.os }}-pods-
90+
13191
- name: Install Pods
13292
working-directory: example/ios
13393
run: pod install
94+
13495
- name: Build App
13596
working-directory: example/ios
136-
run: "set -o pipefail && xcodebuild \
137-
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
138-
-derivedDataPath build -UseModernBuildSystem=YES \
139-
-workspace $$exampleApp$$.xcworkspace \
140-
-scheme $$exampleApp$$ \
141-
-sdk iphonesimulator \
142-
-configuration Debug \
143-
-destination 'platform=iOS Simulator,name=iPhone 16' \
144-
build \
145-
CODE_SIGNING_ALLOWED=NO | xcpretty"
97+
run: |
98+
set -o pipefail && xcodebuild \
99+
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
100+
-derivedDataPath build -UseModernBuildSystem=YES \
101+
-workspace $$exampleApp$$.xcworkspace \
102+
-scheme $$exampleApp$$ \
103+
-sdk iphonesimulator \
104+
-configuration Debug \
105+
-destination 'platform=iOS Simulator,name=iPhone 16' \
106+
build \
107+
CODE_SIGNING_ALLOWED=NO | xcpretty

0 commit comments

Comments
 (0)