diff --git a/scripts/releases-ci/__tests__/publish-npm-test.js b/scripts/releases-ci/__tests__/publish-npm-test.js index a494dc31a57e..2fee2e9ab90b 100644 --- a/scripts/releases-ci/__tests__/publish-npm-test.js +++ b/scripts/releases-ci/__tests__/publish-npm-test.js @@ -21,6 +21,7 @@ const getNpmInfoMock = jest.fn(); const generateAndroidArtifactsMock = jest.fn(); const getPackagesMock = jest.fn(); const updateHermesVersionsToNightlyMock = jest.fn(); +const getBranchName = jest.fn(); const {REPO_ROOT} = require('../../shared/consts'); const {publishNpm} = require('../publish-npm'); @@ -38,6 +39,7 @@ describe('publish-npm', () => { exitIfNotOnGit: command => command(), getCurrentCommit: () => 'currentco_mmit', isTaggedLatest: isTaggedLatestMock, + getBranchName: getBranchName, })) .mock('../../releases/utils/release-utils', () => ({ generateAndroidArtifacts: generateAndroidArtifactsMock, @@ -93,12 +95,13 @@ describe('publish-npm', () => { }); describe("publishNpm('dry-run')", () => { - it('should set version and not publish', async () => { + it('should set version, hermes version, and not publish', async () => { const version = '1000.0.0-currentco'; getNpmInfoMock.mockReturnValueOnce({ version, tag: null, }); + getBranchName.mockReturnValueOnce('main'); await publishNpm('dry-run'); @@ -118,6 +121,33 @@ describe('publish-npm', () => { expect(publishExternalArtifactsToMavenMock).not.toHaveBeenCalled(); expect(publishPackageMock).not.toHaveBeenCalled(); }); + + it('should set version, not set hermes version, and not publish', async () => { + const version = '1000.0.0-currentco'; + getNpmInfoMock.mockReturnValueOnce({ + version, + tag: null, + }); + getBranchName.mockReturnValueOnce('0.83-stable'); + + await publishNpm('dry-run'); + + expect(updateHermesVersionsToNightlyMock).not.toHaveBeenCalled(); + expect(setVersionMock).not.toBeCalled(); + expect(updateReactNativeArtifactsMock).toBeCalledWith(version, 'dry-run'); + + // Generate Android artifacts is now delegate to build_android entirely + expect(generateAndroidArtifactsMock).not.toHaveBeenCalled(); + + expect(consoleLogMock).toHaveBeenCalledWith( + 'Skipping `npm publish` because --dry-run is set.', + ); + + // Expect termination + expect(publishAndroidArtifactsToMavenMock).not.toHaveBeenCalled(); + expect(publishExternalArtifactsToMavenMock).not.toHaveBeenCalled(); + expect(publishPackageMock).not.toHaveBeenCalled(); + }); }); describe("publishNpm('nightly')", () => { diff --git a/scripts/releases-ci/publish-npm.js b/scripts/releases-ci/publish-npm.js index 75193c1f4ca7..e0522b77b228 100755 --- a/scripts/releases-ci/publish-npm.js +++ b/scripts/releases-ci/publish-npm.js @@ -26,6 +26,7 @@ const { publishAndroidArtifactsToMaven, publishExternalArtifactsToMaven, } = require('../releases/utils/release-utils'); +const {getBranchName} = require('../releases/utils/scm-utils'); const {REPO_ROOT} = require('../shared/consts'); const {getPackages} = require('../shared/monorepoUtils'); const fs = require('fs'); @@ -119,8 +120,10 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise */ { const packageJson = JSON.parse(packageJsonContent); if (packageJson.version === '1000.0.0') { - // Set hermes versions to latest available - await updateHermesVersionsToNightly(); + // Set hermes versions to latest available if not on a stable branch + if (!/.*-stable/.test(getBranchName())) { + await updateHermesVersionsToNightly(); + } await updateReactNativeArtifacts(version, buildType); } }