Update publish-npm script not to change Hermes versions on stable branches (#54404)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54404

Changelog: [Internal]

Updates the `publish-npm` script, so that it doesn't try to use the latest (nightly) releases of Hermes when invoked on a stable branch before a version is updated from 1000.0.0.

This is the same change as the one used for 0.83 release: https://github.com/facebook/react-native/pull/54402.

Reviewed By: cipolleschi

Differential Revision: D86201041

fbshipit-source-id: 6e6fc2981853ca1218913e224c97fadea48a72f5
This commit is contained in:
Jakub Piasecki authored and meta-codesync[bot] committed 2025-11-04 08:40:01 -08:00
1 parent 7cb10a8222
commit f51973a9d1
2 files changed
+37 -3

No files matched your search

@@ -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')", () => {
+6 -2
View File
@@ -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,11 @@ async function publishNpm(buildType /*: BuildType */) /*: Promise<void> */ {
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);
}
}