From 1c5e0ffd9fa4963b3f0b6ea2d5d0ed661dd8fe3c Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 18 Sep 2025 10:53:25 -0700 Subject: [PATCH] Do not reset the native artifacts version to 1000.0.0 on release branches (#53817) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53817 What is currently happening, is that the various commits on the release branches like `0.82-stable` are resetting the version of native artifacts to `1000.0.0-`. The reason is that during the `test-all` workflow, we pass the `dry-run` as release type. That's to prevent the various tools from calling `npm publish` and so on. The problem is that on the releases branches, the version was already set at branch cut time. Therefore, we see the version 1000.0.0 reappearing during Android E2E test in the emulator. Similary this is also affecting iOS prebuilds so I'm attempting to fix it here. Changelog: [Internal] [Changed] - Reviewed By: huntie Differential Revision: D82553599 fbshipit-source-id: 31a52e7df036e700663b3d3dd677973a7a210a30 --- .github/actions/build-android/action.yml | 3 +++ scripts/releases-ci/publish-npm.js | 25 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/actions/build-android/action.yml b/.github/actions/build-android/action.yml index ac769b62ce9..fe6753af80e 100644 --- a/.github/actions/build-android/action.yml +++ b/.github/actions/build-android/action.yml @@ -17,6 +17,9 @@ runs: - name: Install node dependencies uses: ./.github/actions/yarn-install - name: Set React Native Version + # We don't want to set the version for stable branches, because this has been + # already set from the 'create release' commits on the release branch. + if: ${{ !endsWith(github.ref_name, '-stable') }} shell: bash run: node ./scripts/releases/set-rn-artifacts-version.js --build-type ${{ inputs.release-type }} - name: Setup gradle diff --git a/scripts/releases-ci/publish-npm.js b/scripts/releases-ci/publish-npm.js index 406682dce8c..8d5b8ff2e1f 100755 --- a/scripts/releases-ci/publish-npm.js +++ b/scripts/releases-ci/publish-npm.js @@ -25,6 +25,7 @@ const { } = require('../releases/utils/release-utils'); const {REPO_ROOT} = require('../shared/consts'); const {getPackages} = require('../shared/monorepoUtils'); +const fs = require('fs'); const path = require('path'); const yargs = require('yargs'); @@ -94,12 +95,24 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise */ { const {version, tag} = getNpmInfo(buildType); // For stable releases, ci job `prepare_package_for_release` handles this - if (['dry-run', 'nightly'].includes(buildType)) { - if (buildType === 'nightly') { - // Set same version for all monorepo packages - await setVersion(version); - await publishMonorepoPackages(tag); - } else { + if (buildType === 'nightly') { + // Set same version for all monorepo packages + await setVersion(version); + await publishMonorepoPackages(tag); + } else if (buildType === 'dry-run') { + // Before updating React Native artifacts versions for dry-run, we check if the version has already been set. + // If it has, we don't need to update the artifacts at all (at this will revert them back to 1000.0.0) + // If it hasn't, we can update the native artifacts accordingly. + const reactNativePackageJson = path.join( + REPO_ROOT, + 'packages', + 'react-native', + 'package.json', + ); + const packageJsonContent = fs.readFileSync(reactNativePackageJson, 'utf8'); + const packageJson = JSON.parse(packageJsonContent); + + if (packageJson.version === '1000.0.0') { await updateReactNativeArtifacts(version, buildType); } }