Skip to content

Commit 69bd172

Browse files
committed
chore: add RNRepo to CI builds
1 parent 40d7233 commit 69bd172

5 files changed

Lines changed: 57 additions & 0 deletions

File tree

apps/example/android/app/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ apply plugin: "com.android.application"
22
apply plugin: "org.jetbrains.kotlin.android"
33
apply plugin: "com.facebook.react"
44

5+
def isCIEnabled() {
6+
return ["1", "true"].contains(System.getenv("CI")?.toLowerCase())
7+
}
8+
9+
def isRNRepoEnabled() {
10+
// return false // Uncomment to disable RNRepo locally
11+
return System.getenv("DISABLE_RNREPO") == null
12+
}
13+
14+
// Use RNRepo in CI builds.
15+
// Set DISABLE_RNREPO to any value to disable RNRepo.
16+
if (isCIEnabled() && isRNRepoEnabled()) {
17+
apply plugin: "org.rnrepo.tools.prebuilds-plugin"
18+
}
19+
520
/**
621
* This is the configuration block to customize your React Native Android app.
722
* By default you don't need to apply any configuration, just uncomment the lines you need.

apps/example/android/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ buildscript {
1111
google()
1212
mavenCentral()
1313
}
14+
// RNRepo plugin classpath for CI builds (plugin applied in app/build.gradle).
15+
// To disable RNRepo support, set DISABLE_RNREPO environment variable to ANY value.
16+
def rnrepoClasspath = {
17+
def rnrepoDir = new File(
18+
providers.exec {
19+
workingDir(rootDir)
20+
commandLine("node", "--print", "require.resolve('@rnrepo/build-tools/package.json')")
21+
}.standardOutput.asText.get().trim()
22+
).getParentFile().absolutePath
23+
return fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin.jar"])
24+
}
1425
dependencies {
1526
classpath("com.android.tools.build:gradle")
1627
classpath("com.facebook.react:react-native-gradle-plugin")
1728
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
29+
classpath rnrepoClasspath()
1830
}
1931
}
2032

apps/example/ios/Podfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ require Pod::Executable.execute_command('node', ['-p',
1010
{paths: [process.argv[1]]},
1111
)', __dir__]).strip
1212

13+
def is_ci_enabled?
14+
%w[1 true].include?(ENV['CI'].to_s.downcase)
15+
end
16+
17+
# ENV['DISABLE_RNREPO'] = "1" # Uncomment to disable RNRepo even in CI
18+
def is_rnrepo_enabled?
19+
ENV['DISABLE_RNREPO'].nil?
20+
end
21+
22+
# Use RNRepo in CI builds. Set DISABLE_RNREPO to any value to disable RNRepo.
23+
if is_ci_enabled? && is_rnrepo_enabled?
24+
require Pod::Executable.execute_command('node', ['-p',
25+
'require.resolve(
26+
"@rnrepo/build-tools/cocoapods-plugin/lib/plugin.rb",
27+
{paths: [process.argv[1]]},
28+
)', __dir__]).strip
29+
end
30+
1331
platform :ios, min_ios_version_supported
1432
prepare_react_native_project!
1533

@@ -29,6 +47,9 @@ target 'EnrichedMarkdownExample' do
2947
)
3048

3149
post_install do |installer|
50+
if is_ci_enabled? && is_rnrepo_enabled?
51+
rnrepo_post_install(installer)
52+
end
3253
react_native_post_install(
3354
installer,
3455
config[:reactNativePath],

apps/example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@react-native/babel-preset": "0.84.1",
3030
"@react-native/metro-config": "0.84.1",
3131
"@react-native/typescript-config": "0.84.1",
32+
"@rnrepo/build-tools": "~0.1.3-beta.0",
3233
"@types/react": "^19.2.0",
3334
"react-native-builder-bob": "^0.40.18",
3435
"react-native-monorepo-config": "^0.3.3",

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4846,6 +4846,13 @@ __metadata:
48464846
languageName: node
48474847
linkType: hard
48484848

4849+
"@rnrepo/build-tools@npm:~0.1.3-beta.0":
4850+
version: 0.1.3-beta.0
4851+
resolution: "@rnrepo/build-tools@npm:0.1.3-beta.0"
4852+
checksum: 10c0/83d2c2b05d87ab038d139c56b2e8ea1df071c41a51094a6464d9c7bc5794f25eb289b8b9298418e829d9ebfe723a77d5556fb1eaf69d87b25dda1f7d19d2d5fb
4853+
languageName: node
4854+
linkType: hard
4855+
48494856
"@sideway/address@npm:^4.1.5":
48504857
version: 4.1.5
48514858
resolution: "@sideway/address@npm:4.1.5"
@@ -13434,6 +13441,7 @@ __metadata:
1343413441
"@react-native/typescript-config": "npm:0.84.1"
1343513442
"@react-navigation/native": "npm:^7.2.2"
1343613443
"@react-navigation/native-stack": "npm:^7.14.12"
13444+
"@rnrepo/build-tools": "npm:~0.1.3-beta.0"
1343713445
"@types/react": "npm:^19.2.0"
1343813446
react: "npm:19.2.3"
1343913447
react-native: "npm:0.84.1"

0 commit comments

Comments
 (0)