Skip to content

Commit 3bfcb9a

Browse files
committed
fix(ci): commit changes from bumping packages
1 parent 097c141 commit 3bfcb9a

File tree

4 files changed

+32
-82
lines changed

4 files changed

+32
-82
lines changed

packages/build/src/npm-packages/bump.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,17 @@ export function bumpAuxiliaryPackages() {
105105
},
106106
});
107107
}
108+
109+
export function commitBumpedPackages() {
110+
spawnSync('git', ['add', '.'], {
111+
stdio: 'inherit',
112+
cwd: PROJECT_ROOT,
113+
encoding: 'utf8',
114+
});
115+
116+
spawnSync('git', ['commit', '-m', 'chore(release): bump packages'], {
117+
stdio: 'inherit',
118+
cwd: PROJECT_ROOT,
119+
encoding: 'utf8',
120+
});
121+
}

packages/build/src/npm-packages/publish.spec.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { publishToNpm } from './publish';
66

77
describe('npm-packages publishToNpm', function () {
88
let listNpmPackages: SinonStub;
9-
let markBumpedFilesAsAssumeUnchanged: SinonStub;
109
let spawnSync: SinonStub;
1110
const lernaBin = path.resolve(
1211
__dirname,
@@ -21,7 +20,6 @@ describe('npm-packages publishToNpm', function () {
2120

2221
beforeEach(function () {
2322
listNpmPackages = sinon.stub();
24-
markBumpedFilesAsAssumeUnchanged = sinon.stub();
2523
spawnSync = sinon.stub();
2624
});
2725

@@ -32,17 +30,8 @@ describe('npm-packages publishToNpm', function () {
3230
];
3331
listNpmPackages.returns(packages);
3432

35-
publishToNpm(
36-
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
37-
listNpmPackages,
38-
markBumpedFilesAsAssumeUnchanged,
39-
spawnSync
40-
);
33+
publishToNpm({ isDryRun: false }, listNpmPackages);
4134

42-
expect(markBumpedFilesAsAssumeUnchanged).to.have.been.calledWith(
43-
packages,
44-
true
45-
);
4635
expect(spawnSync).to.have.been.calledWith(
4736
lernaBin,
4837
[
@@ -56,36 +45,5 @@ describe('npm-packages publishToNpm', function () {
5645
],
5746
sinon.match.any
5847
);
59-
expect(markBumpedFilesAsAssumeUnchanged).to.have.been.calledWith(
60-
packages,
61-
false
62-
);
63-
});
64-
65-
it('reverts the assume unchanged even on spawn failure', function () {
66-
const packages = [{ name: 'packageA', version: '0.7.0' }];
67-
listNpmPackages.returns(packages);
68-
spawnSync.throws(new Error('meeep'));
69-
70-
try {
71-
publishToNpm(
72-
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
73-
listNpmPackages,
74-
markBumpedFilesAsAssumeUnchanged,
75-
spawnSync
76-
);
77-
} catch (e: any) {
78-
expect(markBumpedFilesAsAssumeUnchanged).to.have.been.calledWith(
79-
packages,
80-
true
81-
);
82-
expect(spawnSync).to.have.been.called;
83-
expect(markBumpedFilesAsAssumeUnchanged).to.have.been.calledWith(
84-
packages,
85-
false
86-
);
87-
return;
88-
}
89-
expect.fail('Expected error');
9048
});
9149
});

packages/build/src/npm-packages/publish.ts

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import path from 'path';
2-
import {
3-
EXCLUDE_RELEASE_PACKAGES,
4-
LERNA_BIN,
5-
MONGOSH_RELEASE_PACKAGES,
6-
PROJECT_ROOT,
7-
} from './constants';
2+
import { LERNA_BIN, PROJECT_ROOT } from './constants';
83
import type { LernaPackageDescription } from './list';
9-
import { listNpmPackages as listNpmPackagesFn } from './list';
104
import { spawnSync as spawnSyncFn } from '../helpers/spawn-sync';
115
import type { SpawnSyncOptionsWithStringEncoding } from 'child_process';
126

137
export function publishToNpm(
14-
{ isDryRun = false, useAuxiliaryPackagesOnly = false },
15-
listNpmPackages: typeof listNpmPackagesFn = listNpmPackagesFn,
16-
markBumpedFilesAsAssumeUnchangedFn: typeof markBumpedFilesAsAssumeUnchanged = markBumpedFilesAsAssumeUnchanged,
8+
{ isDryRun = false },
179
spawnSync: typeof spawnSyncFn = spawnSyncFn
1810
): void {
1911
const commandOptions: SpawnSyncOptionsWithStringEncoding = {
@@ -25,37 +17,22 @@ export function publishToNpm(
2517
...(isDryRun ? { npm_config_dry_run: 'true' } : {}),
2618
},
2719
};
28-
const allReleasablePackages = listNpmPackages().filter(
29-
(packageConfig) => !EXCLUDE_RELEASE_PACKAGES.includes(packageConfig.name)
30-
);
31-
32-
const packages: LernaPackageDescription[] = useAuxiliaryPackagesOnly
33-
? allReleasablePackages.filter(
34-
(packageConfig) =>
35-
!MONGOSH_RELEASE_PACKAGES.includes(packageConfig.name)
36-
)
37-
: allReleasablePackages;
3820

3921
// Lerna requires a clean repository for a publish from-package
4022
// we use git update-index --assume-unchanged on files we know have been bumped
41-
markBumpedFilesAsAssumeUnchangedFn(packages, true);
42-
try {
43-
spawnSync(
44-
LERNA_BIN,
45-
[
46-
'publish',
47-
'from-package',
48-
'--no-private',
49-
'--no-changelog',
50-
'--exact',
51-
'--yes',
52-
'--no-verify-access',
53-
],
54-
commandOptions
55-
);
56-
} finally {
57-
markBumpedFilesAsAssumeUnchangedFn(packages, false);
58-
}
23+
spawnSync(
24+
LERNA_BIN,
25+
[
26+
'publish',
27+
'from-package',
28+
'--no-private',
29+
'--no-changelog',
30+
'--exact',
31+
'--yes',
32+
'--no-verify-access',
33+
],
34+
commandOptions
35+
);
5936
}
6037

6138
export function markBumpedFilesAsAssumeUnchanged(

packages/build/src/publish-mongosh.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
bumpMongoshReleasePackages as bumpMongoshReleasePackagesFn,
1919
bumpAuxiliaryPackages as bumpAuxiliaryPackagesFn,
2020
} from './npm-packages';
21+
import { commitBumpedPackages } from './npm-packages/bump';
2122

2223
export async function publishMongosh(
2324
config: Config,
@@ -67,6 +68,7 @@ export async function publishMongosh(
6768

6869
bumpAuxiliaryPackages();
6970
await bumpMongoshReleasePackages(releaseVersion);
71+
commitBumpedPackages();
7072

7173
await publishArtifactsToBarque(
7274
barque,
@@ -94,7 +96,6 @@ export async function publishMongosh(
9496

9597
publishToNpm({
9698
isDryRun: config.isDryRun,
97-
useAuxiliaryPackagesOnly: config.useAuxiliaryPackagesOnly,
9899
});
99100

100101
await publishToHomebrew(

0 commit comments

Comments
 (0)