Skip to content

Commit 325b7ca

Browse files
committed
feat: build ios and android example apps on CI
1 parent c69d9b3 commit 325b7ca

File tree

5 files changed

+102
-20
lines changed

5 files changed

+102
-20
lines changed

.github/workflows/build-templates.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ jobs:
113113
--repo-url https://test.test \
114114
--type ${{ matrix.type }} \
115115
--languages ${{ matrix.language }} \
116-
--turborepo
117116
118117
- name: Cache dependencies of library
119118
id: library-yarn-cache

packages/create-react-native-library/src/index.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const FALLBACK_BOB_VERSION = '0.20.0';
1616
const BINARIES = /(gradlew|\.(jar|keystore|png|jpg|gif))$/;
1717

1818
const COMMON_FILES = path.resolve(__dirname, '../templates/common');
19-
const TURBOREPO_FILES = path.resolve(__dirname, '../templates/turborepo');
2019
const JS_FILES = path.resolve(__dirname, '../templates/js-library');
2120
const EXPO_FILES = path.resolve(__dirname, '../templates/expo-library');
2221
const CPP_FILES = path.resolve(__dirname, '../templates/cpp-library');
@@ -80,8 +79,7 @@ type ArgName =
8079
| 'repo-url'
8180
| 'languages'
8281
| 'type'
83-
| 'react-native-version'
84-
| 'turborepo';
82+
| 'react-native-version';
8583

8684
type ProjectLanguages =
8785
| 'java-objc'
@@ -110,7 +108,6 @@ type Answers = {
110108
languages: ProjectLanguages;
111109
type?: ProjectType;
112110
reactNativeVersion?: string;
113-
turborepo?: boolean;
114111
};
115112

116113
const LANGUAGE_CHOICES: {
@@ -246,10 +243,6 @@ const args: Record<ArgName, yargs.Options> = {
246243
description: 'Version of React Native to use, uses latest if not specified',
247244
type: 'string',
248245
},
249-
'turborepo': {
250-
description: 'Whether to configure Turborepo for the project',
251-
type: 'boolean',
252-
},
253246
};
254247

255248
async function create(argv: yargs.Arguments<any>) {
@@ -455,7 +448,6 @@ async function create(argv: yargs.Arguments<any>) {
455448
type = 'module-mixed',
456449
languages = type === 'library' ? 'js' : 'java-objc',
457450
reactNativeVersion,
458-
turborepo,
459451
} = {
460452
...argv,
461453
...(await prompts(
@@ -582,7 +574,6 @@ async function create(argv: yargs.Arguments<any>) {
582574
},
583575
repo: repoUrl,
584576
example,
585-
turborepo,
586577
year: new Date().getFullYear(),
587578
};
588579

@@ -645,10 +636,6 @@ async function create(argv: yargs.Arguments<any>) {
645636

646637
await copyDir(COMMON_FILES, folder);
647638

648-
if (turborepo) {
649-
await copyDir(TURBOREPO_FILES, folder);
650-
}
651-
652639
if (languages === 'js') {
653640
await copyDir(JS_FILES, folder);
654641
await copyDir(EXPO_FILES, folder);

packages/create-react-native-library/templates/common/$.github/workflows/ci.yml

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Run unit tests
3636
run: yarn test --maxWorkers=2 --coverage
3737

38-
build:
38+
build-library:
3939
runs-on: ubuntu-latest
4040
steps:
4141
- name: Checkout
@@ -46,3 +46,101 @@ jobs:
4646

4747
- name: Build package
4848
run: yarn prepack
49+
50+
<% if (project.native) { -%>
51+
build-android:
52+
runs-on: ubuntu-latest
53+
env:
54+
TURBO_CACHE_DIR: .turbo/android
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v3
58+
59+
- name: Setup
60+
uses: ./.github/actions/setup
61+
62+
- name: Install JDK
63+
uses: actions/setup-java@v3
64+
with:
65+
distribution: 'zulu'
66+
java-version: '11'
67+
68+
- name: Finalize Android SDK
69+
run: |
70+
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
71+
72+
- name: Cache turborepo for Android
73+
uses: actions/cache@v3
74+
with:
75+
path: ${{ env.TURBO_CACHE_DIR }}
76+
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('**/yarn.lock') }}
77+
restore-keys: |
78+
${{ runner.os }}-library-turborepo-android-
79+
80+
- name: Cache Gradle
81+
uses: actions/cache@v3
82+
with:
83+
path: |
84+
~/.gradle/wrapper
85+
~/.gradle/caches
86+
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
87+
88+
- name: Build example for Android
89+
run: |
90+
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
91+
92+
build-ios:
93+
runs-on: macos-latest
94+
env:
95+
TURBO_CACHE_DIR: .turbo/ios
96+
steps:
97+
- name: Checkout
98+
uses: actions/checkout@v3
99+
100+
- name: Setup
101+
uses: ./.github/actions/setup
102+
103+
- name: Cache turborepo for iOS
104+
uses: actions/cache@v3
105+
with:
106+
path: ${{ env.TURBO_CACHE_DIR }}
107+
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('**/yarn.lock') }}
108+
restore-keys: |
109+
${{ runner.os }}-library-turborepo-ios-
110+
111+
- name: Cache cocoapods
112+
id: cocoapods-cache
113+
uses: actions/cache@v3
114+
with:
115+
path: |
116+
**/ios/Pods
117+
**/ios/Podfile.lock
118+
key: ${{ runner.os }}-cocoapods-${{ hashFiles('**/Podfile') }}-${{ hashFiles('**/yarn.lock') }}
119+
restore-keys: |
120+
${{ runner.os }}-cocoapods-${{ hashFiles('**/Podfile') }}-
121+
${{ runner.os }}-cocoapods-
122+
123+
- name: Install cocoapods
124+
if: steps.cocoapods-cache.outputs.cache-hit != 'true'
125+
run: |
126+
yarn example pods
127+
env:
128+
NO_FLIPPER: 1
129+
130+
- name: Build example (iOS)
131+
run: |
132+
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
133+
<% } else { -%>
134+
build-web:
135+
runs-on: ubuntu-latest
136+
steps:
137+
- name: Checkout
138+
uses: actions/checkout@v3
139+
140+
- name: Setup
141+
uses: ./.github/actions/setup
142+
143+
- name: Build example for Web
144+
run: |
145+
yarn example expo export:web
146+
<% } -%>

packages/create-react-native-library/templates/common/$package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@
3333
"prepack": "bob build",
3434
"release": "release-it",
3535
"example": "yarn --cwd example",
36-
<% if (example === 'native' && turborepo) { -%>
36+
<% if (example === 'native') { -%>
3737
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
3838
"build:ios": "cd example/ios && xcodebuild -workspace <%- project.name %>Example.xcworkspace -scheme <%- project.name %>Example -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
39-
<% } -%>
40-
<% if (example === 'native') { -%>
4139
"bootstrap": "yarn example && yarn install && yarn example pods",
4240
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
4341
<% } else { -%>
@@ -79,7 +77,7 @@
7977
"react-native": "0.70.0",
8078
"react-native-builder-bob": "^<%- bob.version %>",
8179
"release-it": "^15.0.0",
82-
<% if (turborepo) { -%>
80+
<% if (example === 'native') { -%>
8381
"turbo": "^1.10.7",
8482
<% } -%>
8583
"typescript": "^5.0.2"

0 commit comments

Comments
 (0)