Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion scripts/releases-ci/__tests__/publish-npm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -38,6 +39,7 @@ describe('publish-npm', () => {
exitIfNotOnGit: command => command(),
getCurrentCommit: () => 'currentco_mmit',
isTaggedLatest: isTaggedLatestMock,
getBranchName: getBranchName,
}))
.mock('../../releases/utils/release-utils', () => ({
generateAndroidArtifacts: generateAndroidArtifactsMock,
Expand Down Expand Up @@ -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');

Expand All @@ -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')", () => {
Expand Down
7 changes: 5 additions & 2 deletions scripts/releases-ci/publish-npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
}
}
Expand Down
Loading