Skip to content

Commit 5dd90c5

Browse files
authored
Use content hash for react-native builds (#26734)
1 parent 559e83a commit 5dd90c5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/commit_artifacts.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,16 @@ jobs:
228228
name: compiled-rn
229229
path: compiled-rn/
230230
- run: git status -u
231+
- name: Check if only the REVISION file has changed
232+
id: check_should_commit
233+
run: |
234+
if git status --porcelain | grep -qv '/REVISION$'; then
235+
echo "should_commit=true" >> "$GITHUB_OUTPUT"
236+
else
237+
echo "should_commit=false" >> "$GITHUB_OUTPUT"
238+
fi
231239
- name: Commit changes to branch
240+
if: steps.check_should_commit.outputs.should_commit == 'true'
232241
uses: stefanzweifel/git-auto-commit-action@v4
233242
with:
234243
commit_message: |

scripts/rollup/build-all-release-channels.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,26 @@ function processStable(buildDir) {
177177
);
178178
}
179179

180+
const reactNativeBuildDir = buildDir + '/react-native/implementations/';
181+
if (fs.existsSync(reactNativeBuildDir)) {
182+
const hash = crypto.createHash('sha1');
183+
for (const fileName of fs.readdirSync(reactNativeBuildDir).sort()) {
184+
const filePath = reactNativeBuildDir + fileName;
185+
const stats = fs.statSync(filePath);
186+
if (!stats.isDirectory()) {
187+
hash.update(fs.readFileSync(filePath));
188+
}
189+
}
190+
updatePlaceholderReactVersionInCompiledArtifacts(
191+
reactNativeBuildDir,
192+
ReactVersion +
193+
'-' +
194+
nextChannelLabel +
195+
'-' +
196+
hash.digest('hex').slice(0, 8)
197+
);
198+
}
199+
180200
// Update remaining placeholders with next channel version
181201
updatePlaceholderReactVersionInCompiledArtifacts(
182202
buildDir,

0 commit comments

Comments
 (0)