Don't update Hermes versions to latest on stable branch before version is updated (#54402)

This commit is contained in:
Jakub Piasecki authored and GitHub committed 2025-11-04 12:36:17 +01:00
1 parent e23a285ffe
commit 6dc0f2db6d
2 files changed
+36 -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')", () => {
+5 -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,10 @@ 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);
}
}