Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/build-library-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@ jobs:
- name: πŸ“¦ Install dependencies
run: bun install

- name: ♻️ Restore RN project cache
id: rn-project-cache
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/rnrepo_build_app
key: ${{ runner.os }}-rn-project-cache-${{ inputs.react_native_version }}

- name: πŸ“± Create RN project (cache miss)
if: steps.rn-project-cache.outputs.cache-hit != 'true'
run: |
work_dir="${{ runner.temp }}"
mkdir -p "$work_dir"
cd "$work_dir"
bunx @react-native-community/cli@latest init rnrepo_build_app --version "${{ inputs.react_native_version }}" --skip-install
cd "$work_dir/rnrepo_build_app"
npm install

- name: πŸ’Ύ Save RN project cache (clean)
if: steps.rn-project-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/rnrepo_build_app
key: ${{ runner.os }}-rn-project-cache-${{ inputs.react_native_version }}

- name: πŸ”¨ Build library for Android
run: bun run packages/builder/build-library-android.ts -- "${{ inputs.library_name }}" "${{ inputs.library_version }}" "${{ inputs.react_native_version }}" "${{ runner.temp }}" "${{ inputs.worklets_version }}"

Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/build-library-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ jobs:
- name: πŸ“¦ Install dependencies
run: bun install

- name: ♻️ Restore RN project cache
id: rn-project-cache
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/rnrepo_build_app
key: ${{ runner.os }}-rn-project-cache-${{ inputs.react_native_version }}

- name: πŸ“± Create RN project (cache miss)
if: steps.rn-project-cache.outputs.cache-hit != 'true'
run: |
work_dir="${{ runner.temp }}"
mkdir -p "$work_dir"
cd "$work_dir"
bunx @react-native-community/cli@latest init rnrepo_build_app --version "${{ inputs.react_native_version }}" --skip-install
cd "$work_dir/rnrepo_build_app"
npm install

- name: πŸ’Ύ Save RN project cache (clean)
if: steps.rn-project-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/rnrepo_build_app
key: ${{ runner.os }}-rn-project-cache-${{ inputs.react_native_version }}

- name: πŸ”¨ Build library for iOS
run: bun run packages/builder/build-library-ios.ts -- "${{ inputs.library_name }}" "${{ inputs.library_version }}" "${{ inputs.react_native_version }}" "${{ runner.temp }}" "${{ inputs.worklets_version }}"

Expand Down
24 changes: 14 additions & 10 deletions packages/builder/build-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,23 @@ export async function setupReactNativeProject(
const { mkdirSync } = await import('fs');
mkdirSync(workDir, { recursive: true });

// Check that app directory doesn't exist yet
// If appDir already exists, assume it's a cached RN project and skip setup
if (existsSync(appDir)) {
throw new Error(`App directory ${appDir} already exists.`);
}
console.log(`♻️ Using cached React Native project at ${appDir}`);
} else {
// Create RN project in the work directory
console.log(
`πŸ“± Creating temporary React Native project (RN ${reactNativeVersion})...`
);

// Create RN project in the work directory
console.log(
`πŸ“± Creating temporary React Native project (RN ${reactNativeVersion})...`
);
await $`bunx @react-native-community/cli@latest init rnrepo_build_app --version ${reactNativeVersion} --skip-install`
.cwd(workDir)
.quiet();
}

await $`bunx @react-native-community/cli@latest init rnrepo_build_app --version ${reactNativeVersion} --skip-install`
.cwd(workDir)
.quiet();
if (!existsSync(join(appDir, 'package.json'))) {
throw new Error(`Invalid React Native project at ${appDir}`);
}

// Perform any library-specific setup before installing
await installSetup(appDir, libraryName, 'preInstall');
Expand Down