Use content hash for react-native builds (#26734)
Samuel Susla committed
May 2, 2023 at 12:04 UTC
5dd90c562354758942c833b0a46923176e92208e
2 files changed
+29
.github/workflows/commit_artifacts.yml
+9
@@ -228,7 +228,16 @@ jobs:
228
name: compiled-rn
229
path: compiled-rn/
230
- 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
239
- name: Commit changes to branch
240
+ if: steps.check_should_commit.outputs.should_commit == 'true'
241
uses: stefanzweifel/git-auto-commit-action@v4
242
with:
243
commit_message: |
scripts/rollup/build-all-release-channels.js
+20
@@ -177,6 +177,26 @@ function processStable(buildDir) {
177
);
178
}
179
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
+
200
// Update remaining placeholders with next channel version
201
updatePlaceholderReactVersionInCompiledArtifacts(
202
buildDir,