Skip to content

Commit 59f01d1

Browse files
Add Support for patches in nightly (#38)
1 parent a384f97 commit 59f01d1

File tree

13 files changed

+234
-3
lines changed

13 files changed

+234
-3
lines changed

.github/actions/test-library-on-nightly/action.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ inputs:
1111
description: Number of retry attempts for failed operations
1212
required: false
1313
default: '3'
14+
patch-file:
15+
description: Optional path to a patch file to apply after installing the library
16+
required: false
17+
default: ''
1418
runs:
1519
using: composite
1620
steps:
@@ -19,6 +23,22 @@ runs:
1923
run: |
2024
cd /tmp
2125
npx @react-native-community/cli init RNApp --skip-install --version nightly
26+
27+
28+
- name: Apply patch if specified
29+
if: ${{ inputs.patch-file != '' }}
30+
shell: bash
31+
run: |
32+
if [ -f "$GITHUB_WORKSPACE/${{ inputs.patch-file }}" ]; then
33+
echo "Applying patch: ${{ inputs.patch-file }}"
34+
cd /tmp/RNApp
35+
node "$GITHUB_WORKSPACE/scripts/apply-patch.js" "$GITHUB_WORKSPACE/${{ inputs.patch-file }}"
36+
echo "✅ Patch applied successfully"
37+
else
38+
echo "⚠️ Warning: Patch file not found: ${{ inputs.patch-file }}"
39+
exit 1
40+
fi
41+
2242
- name: Add library with retry
2343
uses: nick-fields/retry@v3
2444
with:

.github/workflows/check-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ jobs:
4545
firebase_app_email: ${{ secrets.FIREBASE_APP_EMAIL }}
4646
firebase_app_pass: ${{ secrets.FIREBASE_APP_PASS }}
4747
firebase_app_projectname: ${{ secrets.FIREBASE_APP_PROJECTNAME }}
48-
firebase_app_apikey: ${{ secrets.FIREBASE_APP_APIKEY }}
48+
firebase_app_apikey: ${{ secrets.FIREBASE_APP_APIKEY }}

.github/workflows/pr-check-new-entries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ jobs:
6262
with:
6363
library-npm-package: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].installCommand }}
6464
platform: ${{ matrix.platform }}
65+
patch-file: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].patchFile || '' }}

.github/workflows/test-libraries-on-nightlies.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
with:
5959
library-npm-package: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].installCommand }}
6060
platform: ${{ matrix.platform }}
61+
patch-file: ${{ fromJSON(needs.runner-setup.outputs.library-data)[matrix.library].patchFile || '' }}
6162
- name: Save outcome
6263
id: save-outcome
6364
if: always()
@@ -71,7 +72,7 @@ jobs:
7172
with:
7273
name: ${{ steps.save-outcome.outputs.lib_folder }}-${{ matrix.platform }}-outcome
7374
path: /tmp/${{ steps.save-outcome.outputs.lib_folder }}-${{ matrix.platform }}-outcome
74-
75+
7576
collect-results:
7677
runs-on: ubuntu-latest
7778
needs: [test-library-on-nightly]

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,8 @@ jspm_packages/
5959
!.yarn/releases
6060
!.yarn/sdks
6161
!.yarn/versions
62+
63+
#Tmp Templates
64+
tmp/
65+
66+

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ The repository includes Jest tests for the workflow scripts. To run the tests lo
4040
yarn install && yarn test
4141
```
4242

43+
### Working with Patch Files
44+
45+
Some libraries may require modifications to the React Native template (e.g., editing pod files, manifest files) to work properly with nightly builds. For detailed instructions on creating and applying patch files, see the [Patch Instructions](patch.md) guide.
46+
4347
## 📄 License
4448

4549
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

libraries.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787
"maintainersUsernames": [],
8888
"notes": ""
8989
},
90+
"react-native-firebase": {
91+
"description": "🔥 A well-tested feature-rich modular Firebase implementation for React Native",
92+
"installCommand": "@react-native-firebase/app",
93+
"android": true,
94+
"ios": true,
95+
"maintainersUsernames": [],
96+
"notes": "",
97+
"patchFile": "patches/react-native-firebase.patch"
98+
},
9099
"react-native-svg": {
91100
"description": "SVG library for React Native, React Native Web, and plain React web projects",
92101
"installCommand": "react-native-svg",
@@ -116,7 +125,7 @@
116125
"installCommand": "react-native-mmkv",
117126
"android": true,
118127
"ios": true,
119-
"maintainersUsernames": [],
128+
"maintainersUsernames": ["mrousavy"],
120129
"notes": ""
121130
},
122131
"react-native-nitro-modules": {

libraries.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@
5050
"Build currently broken due to X reason.",
5151
"One of top most used libraries according to the npm stats."
5252
]
53+
},
54+
"patchFile": {
55+
"type": "string",
56+
"description": "Optional path to a patch file (relative to repo root) to apply after installing the library but before building. Patch should be created using 'git diff --binary' format (e.g., using scripts/make-patch.js).",
57+
"examples": [
58+
"patches/react-native-reanimated.patch",
59+
"patches/library-name-fix.patch"
60+
]
5361
}
5462
},
5563
"required": [

patch.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Patch Instructions
2+
3+
This guide covers how to generate a patch file for your libraries. This is helpful in cases where you need to edit pod files, manifest files, etc.
4+
5+
## How to Generate a Patch File
6+
7+
### Step 1: Create a New Project
8+
9+
Clone this repository, then create a new project with the following command:
10+
11+
```sh
12+
npx @react-native-community/cli@latest init RNApp --version nightly --skip-install --directory tmp/RNApp
13+
```
14+
15+
### Step 2: Navigate to the Directory
16+
17+
```sh
18+
cd tmp/RNApp
19+
```
20+
21+
### Step 3: Make Necessary Changes
22+
23+
Make the necessary changes to the template.
24+
25+
### Step 4: Generate the Patch File
26+
27+
```sh
28+
node ../../scripts/make-patch.js ../../patches/{libraryName}.patch
29+
```
30+
31+
For example:
32+
```sh
33+
node ../../scripts/make-patch.js ../../patches/react-native-turbo-encryption.patch
34+
```
35+
36+
This will generate a patch file in the patches folder.
37+
38+
**Note:** Remove any lock files like `yarn.lock`, `Podfile.lock`, or any generated files that are tracked before generating the patch file, as these can lead to an excessively long patch file.
39+
40+
### Step 5: Verify the Patch File
41+
42+
```sh
43+
node ../../scripts/apply-patch.js ../../patches/{libraryName}.patch
44+
```
45+
For example:
46+
```sh
47+
node ../../scripts/apply-patch.js ../../patches/react-native-turbo-encryption.patch
48+
```
49+
50+
51+
### Step 6: Add the Patch File to `libraries.json`
52+
53+
```json
54+
"react-native-reanimated": {
55+
"description": "React Native's Animated library reimplemented",
56+
"installCommand": "react-native-reanimated@nightly react-native-worklets@nightly",
57+
"android": true,
58+
"ios": true,
59+
"maintainersUsernames": [],
60+
"notes": "",
61+
"patchFile": "patches/reanimated.patch" # <-- Path to patch file
62+
}
63+
```
64+
65+
### Step 7: Submit Your Changes
66+
67+
Push the changes and create a pull request. Your patch file is ready!

patches/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)