Skip to content

Commit 097c141

Browse files
authored
fix(ci): skip pushing tags on a dry run and push all tags on release (#2351)
This is a drive-by fix which makes sure that all tags get pushed when we actually release mongosh.
1 parent 7646b34 commit 097c141

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

packages/build/src/npm-packages/push-tags.spec.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ describe('pushing tags', function () {
5454

5555
expect(() =>
5656
pushTags(
57-
{ useAuxiliaryPackagesOnly: false },
57+
{
58+
isDryRun: false,
59+
useAuxiliaryPackagesOnly: false,
60+
},
5861
listNpmPackages,
5962
existsVersionTag,
6063
spawnSync
@@ -65,6 +68,7 @@ describe('pushing tags', function () {
6568
it('takes mongosh version and pushes tags when releasing', function () {
6669
pushTags(
6770
{
71+
isDryRun: false,
6872
useAuxiliaryPackagesOnly: false,
6973
},
7074
listNpmPackages,
@@ -95,6 +99,7 @@ describe('pushing tags', function () {
9599
it('pushes only package tags when using auxiliary packages', function () {
96100
pushTags(
97101
{
102+
isDryRun: false,
98103
useAuxiliaryPackagesOnly: true,
99104
},
100105
listNpmPackages,
@@ -146,6 +151,7 @@ describe('pushing tags', function () {
146151

147152
pushTags(
148153
{
154+
isDryRun: false,
149155
useAuxiliaryPackagesOnly: true,
150156
},
151157
listNpmPackages,
@@ -194,6 +200,7 @@ describe('pushing tags', function () {
194200
pushTags(
195201
{
196202
useAuxiliaryPackagesOnly: false,
203+
isDryRun: false,
197204
},
198205
listNpmPackages,
199206
existsVersionTag,
@@ -209,5 +216,29 @@ describe('pushing tags', function () {
209216
]);
210217
expect(spawnSync).calledWith('git', ['push', '--follow-tags']);
211218
});
219+
220+
it('skips tag push if it is a dry run', function () {
221+
existsVersionTag.withArgs(`v${mongoshVersion}`).returns(true);
222+
223+
pushTags(
224+
{
225+
useAuxiliaryPackagesOnly: false,
226+
isDryRun: true,
227+
},
228+
listNpmPackages,
229+
existsVersionTag,
230+
spawnSync
231+
);
232+
233+
expect(spawnSync).not.calledWith('git', [
234+
'tag',
235+
'-a',
236+
`v${mongoshVersion}`,
237+
'-m',
238+
`v${mongoshVersion}`,
239+
]);
240+
241+
expect(spawnSync).not.calledWith('git', ['push', '--follow-tags']);
242+
});
212243
});
213244
});

packages/build/src/npm-packages/push-tags.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { listNpmPackages as listNpmPackagesFn } from './list';
99
import { spawnSync as spawnSyncFn } from '../helpers/spawn-sync';
1010

1111
export function pushTags(
12-
{ useAuxiliaryPackagesOnly }: { useAuxiliaryPackagesOnly: boolean },
12+
{
13+
useAuxiliaryPackagesOnly,
14+
isDryRun,
15+
}: { useAuxiliaryPackagesOnly: boolean; isDryRun: boolean },
1316
listNpmPackages: typeof listNpmPackagesFn = listNpmPackagesFn,
1417
existsVersionTag: typeof existsTag = existsTag,
1518
spawnSync: typeof spawnSyncFn = spawnSyncFn
@@ -68,7 +71,9 @@ export function pushTags(
6871
}
6972
}
7073

71-
spawnSync('git', ['push', '--follow-tags'], commandOptions);
74+
if (!isDryRun) {
75+
spawnSync('git', ['push', '--follow-tags'], commandOptions);
76+
}
7277
}
7378

7479
/** Returns true if the tag exists in the remote repository. */

packages/build/src/publish-auxiliary.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ export function publishAuxiliaryPackages(config: Config) {
88
);
99
}
1010
publishToNpm(config);
11-
pushTags({ useAuxiliaryPackagesOnly: true });
11+
pushTags({
12+
useAuxiliaryPackagesOnly: true,
13+
isDryRun: config.isDryRun || false,
14+
});
1215
}

packages/build/src/publish-mongosh.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ export async function publishMongosh(
105105
!!config.isDryRun
106106
);
107107

108-
pushTags({ useAuxiliaryPackagesOnly: true });
108+
pushTags({
109+
useAuxiliaryPackagesOnly: false,
110+
isDryRun: config.isDryRun || false,
111+
});
109112

110113
console.info('mongosh: finished release process.');
111114
}

0 commit comments

Comments
 (0)