diff --git a/.github/actions/build-android/action.yml b/.github/actions/build-android/action.yml index ac769b62ce95..fe6753af80ee 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 406682dce8ca..8d5b8ff2e1f1 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); } }