diff --git a/scripts/releases-ci/__tests__/publish-npm-test.js b/scripts/releases-ci/__tests__/publish-npm-test.js index 5c830c1e535236..bf73c8917b4c85 100644 --- a/scripts/releases-ci/__tests__/publish-npm-test.js +++ b/scripts/releases-ci/__tests__/publish-npm-test.js @@ -14,6 +14,7 @@ const exitMock = jest.fn(); const consoleErrorMock = jest.fn(); const isTaggedLatestMock = jest.fn(); const setVersionMock = jest.fn(); +const setReactNativeVersionMock = jest.fn(); const publishAndroidArtifactsToMavenMock = jest.fn(); const removeNewArchFlags = jest.fn(); const env = process.env; @@ -34,6 +35,9 @@ jest publishAndroidArtifactsToMaven: publishAndroidArtifactsToMavenMock, })) .mock('../../releases/set-version', () => setVersionMock) + .mock('../../releases/set-rn-version', () => ({ + setReactNativeVersion: setReactNativeVersionMock, + })) .mock('../../releases/remove-new-arch-flags', () => ({ removeNewArchFlags, })); @@ -51,6 +55,7 @@ describe('publish-npm', () => { beforeAll(() => { jest.setSystemTime(date); }); + beforeEach(() => { consoleError = console.error; console.error = consoleErrorMock; @@ -59,9 +64,6 @@ describe('publish-npm', () => { afterEach(() => { process.env = env; console.error = consoleError; - }); - - afterEach(() => { jest.resetModules(); jest.resetAllMocks(); }); @@ -84,7 +86,12 @@ describe('publish-npm', () => { expect(echoMock).toHaveBeenCalledWith( 'Skipping `npm publish` because --dry-run is set.', ); - expect(setVersionMock).toBeCalledWith('1000.0.0-currentco'); + expect(setReactNativeVersionMock).toBeCalledWith( + '1000.0.0-currentco', + null, + 'dry-run', + ); + expect(setVersionMock).not.toBeCalled(); }); }); diff --git a/scripts/releases-ci/publish-npm.js b/scripts/releases-ci/publish-npm.js index 57387a04574832..17a663665f1b29 100755 --- a/scripts/releases-ci/publish-npm.js +++ b/scripts/releases-ci/publish-npm.js @@ -17,6 +17,7 @@ import type {BuildType} from '../releases/utils/version-utils'; const {getNpmInfo, publishPackage} = require('../npm-utils'); const {removeNewArchFlags} = require('../releases/remove-new-arch-flags'); +const {setReactNativeVersion} = require('../releases/set-rn-version'); const setVersion = require('../releases/set-version'); const { generateAndroidArtifacts, @@ -73,11 +74,15 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise */ { removeNewArchFlags(); } - // Set same version for all monorepo packages // For stable releases, CircleCI job `prepare_package_for_release` handles this if (['dry-run', 'nightly', 'prealpha'].includes(buildType)) { try { - await setVersion(version); + if (buildType === 'nightly') { + // Set same version for all monorepo packages + await setVersion(version); + } else { + await setReactNativeVersion(version, null, buildType); + } } catch (e) { console.error(`Failed to set version number to ${version}`); console.error(e);