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
33 changes: 32 additions & 1 deletion packages/build/src/npm-packages/push-tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ describe('pushing tags', function () {

expect(() =>
pushTags(
{ useAuxiliaryPackagesOnly: false },
{
isDryRun: false,
useAuxiliaryPackagesOnly: false,
},
listNpmPackages,
existsVersionTag,
spawnSync
Expand All @@ -65,6 +68,7 @@ describe('pushing tags', function () {
it('takes mongosh version and pushes tags when releasing', function () {
pushTags(
{
isDryRun: false,
useAuxiliaryPackagesOnly: false,
},
listNpmPackages,
Expand Down Expand Up @@ -95,6 +99,7 @@ describe('pushing tags', function () {
it('pushes only package tags when using auxiliary packages', function () {
pushTags(
{
isDryRun: false,
useAuxiliaryPackagesOnly: true,
},
listNpmPackages,
Expand Down Expand Up @@ -146,6 +151,7 @@ describe('pushing tags', function () {

pushTags(
{
isDryRun: false,
useAuxiliaryPackagesOnly: true,
},
listNpmPackages,
Expand Down Expand Up @@ -194,6 +200,7 @@ describe('pushing tags', function () {
pushTags(
{
useAuxiliaryPackagesOnly: false,
isDryRun: false,
},
listNpmPackages,
existsVersionTag,
Expand All @@ -209,5 +216,29 @@ describe('pushing tags', function () {
]);
expect(spawnSync).calledWith('git', ['push', '--follow-tags']);
});

it('skips tag push if it is a dry run', function () {
existsVersionTag.withArgs(`v${mongoshVersion}`).returns(true);

pushTags(
{
useAuxiliaryPackagesOnly: false,
isDryRun: true,
},
listNpmPackages,
existsVersionTag,
spawnSync
);

expect(spawnSync).not.calledWith('git', [
'tag',
'-a',
`v${mongoshVersion}`,
'-m',
`v${mongoshVersion}`,
]);

expect(spawnSync).not.calledWith('git', ['push', '--follow-tags']);
});
});
});
9 changes: 7 additions & 2 deletions packages/build/src/npm-packages/push-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { listNpmPackages as listNpmPackagesFn } from './list';
import { spawnSync as spawnSyncFn } from '../helpers/spawn-sync';

export function pushTags(
{ useAuxiliaryPackagesOnly }: { useAuxiliaryPackagesOnly: boolean },
{
useAuxiliaryPackagesOnly,
isDryRun,
}: { useAuxiliaryPackagesOnly: boolean; isDryRun: boolean },
listNpmPackages: typeof listNpmPackagesFn = listNpmPackagesFn,
existsVersionTag: typeof existsTag = existsTag,
spawnSync: typeof spawnSyncFn = spawnSyncFn
Expand Down Expand Up @@ -68,7 +71,9 @@ export function pushTags(
}
}

spawnSync('git', ['push', '--follow-tags'], commandOptions);
if (!isDryRun) {
spawnSync('git', ['push', '--follow-tags'], commandOptions);
}
}

/** Returns true if the tag exists in the remote repository. */
Expand Down
5 changes: 4 additions & 1 deletion packages/build/src/publish-auxiliary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ export function publishAuxiliaryPackages(config: Config) {
);
}
publishToNpm(config);
pushTags({ useAuxiliaryPackagesOnly: true });
pushTags({
useAuxiliaryPackagesOnly: true,
isDryRun: config.isDryRun || false,
});
}
5 changes: 4 additions & 1 deletion packages/build/src/publish-mongosh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ export async function publishMongosh(
!!config.isDryRun
);

pushTags({ useAuxiliaryPackagesOnly: true });
pushTags({
useAuxiliaryPackagesOnly: false,
isDryRun: config.isDryRun || false,
});

console.info('mongosh: finished release process.');
}
Expand Down