Skip to content

Commit

Permalink
Revert "Use content hash for facebook-www builds (#26331)"
Browse files Browse the repository at this point in the history
This reverts commit 3cad3a5.
  • Loading branch information
yungsters committed May 30, 2024
1 parent 182fa82 commit 1155027
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 33 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/commit_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
mkdir -p ${BASE_FOLDER}/react-native-github/Libraries/Renderer/
mkdir -p ${BASE_FOLDER}/RKJSModules/vendor/react/{scheduler,react,react-is,react-test-renderer}/
# Move React Native renderer
# Move React Native renderer
mv build/react-native/implementations/ $BASE_FOLDER/react-native-github/Libraries/Renderer/
mv build/react-native/shims/ $BASE_FOLDER/react-native-github/Libraries/Renderer/
mv build/facebook-react-native/scheduler/cjs/ $BASE_FOLDER/RKJSModules/vendor/react/scheduler/
Expand All @@ -161,9 +161,10 @@ jobs:
rm $RENDERER_FOLDER/ReactNativeRenderer-{dev,prod,profiling}.js
ls -R ./compiled
- name: Add REVISION file
- name: Add REVISION files
run: |
echo ${{ github.sha }} >> ./compiled/facebook-www/REVISION
cp ./compiled/facebook-www/REVISION ./compiled/facebook-www/REVISION_TRANSFORMS
echo ${{ github.sha }} >> ./compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION
- uses: actions/upload-artifact@v3
with:
Expand All @@ -189,16 +190,7 @@ jobs:
name: compiled
path: compiled/
- run: git status -u
- name: Check if only the REVISION file has changed
id: check_should_commit
run: |
if git status --porcelain | grep -qv '/REVISION$'; then
echo "should_commit=true" >> "$GITHUB_OUTPUT"
else
echo "should_commit=false" >> "$GITHUB_OUTPUT"
fi
- name: Commit changes to branch
if: steps.check_should_commit.outputs.should_commit == 'true'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: |
Expand Down
30 changes: 8 additions & 22 deletions scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/* eslint-disable no-for-of-loops/no-for-of-loops */

const crypto = require('node:crypto');
const fs = require('fs');
const fse = require('fs-extra');
const {spawnSync} = require('child_process');
Expand Down Expand Up @@ -41,7 +40,10 @@ if (dateString.startsWith("'")) {

// Build the artifacts using a placeholder React version. We'll then do a string
// replace to swap it with the correct version per release channel.
const PLACEHOLDER_REACT_VERSION = ReactVersion + '-PLACEHOLDER';
//
// The placeholder version is the same format that the "next" channel uses
const PLACEHOLDER_REACT_VERSION =
ReactVersion + '-' + canaryChannelLabel + '-' + sha + '-' + dateString;

// TODO: We should inject the React version using a build-time parameter
// instead of overwriting the source files.
Expand Down Expand Up @@ -158,27 +160,19 @@ function processStable(buildDir) {
}

if (fs.existsSync(buildDir + '/facebook-www')) {
const hash = crypto.createHash('sha1');
for (const fileName of fs.readdirSync(buildDir + '/facebook-www').sort()) {
for (const fileName of fs.readdirSync(buildDir + '/facebook-www')) {
const filePath = buildDir + '/facebook-www/' + fileName;
const stats = fs.statSync(filePath);
if (!stats.isDirectory()) {
hash.update(fs.readFileSync(filePath));
fs.renameSync(filePath, filePath.replace('.js', '.classic.js'));
}
}
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/facebook-www',
ReactVersion + '-www-classic-' + hash.digest('hex').slice(0, 8)
ReactVersion + '-www-classic-' + sha + '-' + dateString
);
}

// Update remaining placeholders with next channel version
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir,
ReactVersion + '-' + canaryChannelLabel + '-' + sha + '-' + dateString
);

if (fs.existsSync(buildDir + '/sizes')) {
fs.renameSync(buildDir + '/sizes', buildDir + '/sizes-stable');
}
Expand Down Expand Up @@ -212,27 +206,19 @@ function processExperimental(buildDir, version) {
}

if (fs.existsSync(buildDir + '/facebook-www')) {
const hash = crypto.createHash('sha1');
for (const fileName of fs.readdirSync(buildDir + '/facebook-www').sort()) {
for (const fileName of fs.readdirSync(buildDir + '/facebook-www')) {
const filePath = buildDir + '/facebook-www/' + fileName;
const stats = fs.statSync(filePath);
if (!stats.isDirectory()) {
hash.update(fs.readFileSync(filePath));
fs.renameSync(filePath, filePath.replace('.js', '.modern.js'));
}
}
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/facebook-www',
ReactVersion + '-www-modern-' + hash.digest('hex').slice(0, 8)
ReactVersion + '-www-modern-' + sha + '-' + dateString
);
}

// Update remaining placeholders with canary channel version
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir,
ReactVersion + '-' + canaryChannelLabel + '-' + sha + '-' + dateString
);

if (fs.existsSync(buildDir + '/sizes')) {
fs.renameSync(buildDir + '/sizes', buildDir + '/sizes-experimental');
}
Expand Down

0 comments on commit 1155027

Please sign in to comment.