Skip to content

Commit 44b857e

Browse files
committed
Merge remote-tracking branch 'origin/master' into 1.24-releases
2 parents 71a8f01 + ae08fbb commit 44b857e

File tree

8 files changed

+87
-78
lines changed

8 files changed

+87
-78
lines changed

package-lock.json

Lines changed: 16 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
"@mongodb-js/compass-collection-stats": "^5.0.5",
261261
"@mongodb-js/compass-collections-ddl": "^3.0.5",
262262
"@mongodb-js/compass-connect": "^5.4.13",
263-
"@mongodb-js/compass-crud": "^10.1.2",
263+
"@mongodb-js/compass-crud": "^10.1.3",
264264
"@mongodb-js/compass-database": "^1.0.1",
265265
"@mongodb-js/compass-databases-ddl": "^3.0.5",
266266
"@mongodb-js/compass-deployment-awareness": "^10.0.7",
@@ -269,7 +269,7 @@
269269
"@mongodb-js/compass-field-store": "^6.0.3",
270270
"@mongodb-js/compass-find-in-page": "^2.0.4",
271271
"@mongodb-js/compass-home": "^4.2.0",
272-
"@mongodb-js/compass-import-export": "^5.1.22",
272+
"@mongodb-js/compass-import-export": "^5.2.2",
273273
"@mongodb-js/compass-indexes": "^3.0.10",
274274
"@mongodb-js/compass-instance": "^2.0.3",
275275
"@mongodb-js/compass-loading": "^1.0.7",
@@ -335,7 +335,7 @@
335335
"mongodb-ace-theme-query": "^0.0.2",
336336
"mongodb-collection-model": "^3.1.0",
337337
"mongodb-connection-model": "^17.0.3",
338-
"mongodb-data-service": "^17.0.3",
338+
"mongodb-data-service": "^17.0.4",
339339
"mongodb-database-model": "^0.1.3",
340340
"mongodb-explain-plan-model": "^0.2.3",
341341
"mongodb-extended-json": "^1.11.0",

release/changelog.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const chalk = require('chalk');
33
const _ = require('lodash');
44
const git = require('./git');
55
const ux = require('./ux');
6+
const version = require('./version');
7+
const semver = require('semver');
68

79
function capitalize(s) {
810
if (typeof s !== 'string') return '';
@@ -19,7 +21,23 @@ function renderCommit({ scope, message, pr, ticket }) {
1921
return `${scope ? `**${scope}**` + ': ' : ''}${capitalize(message)}${links}`;
2022
}
2123

22-
async function render(previousTag, releaseTag) {
24+
async function render(releaseVersion) {
25+
const releaseTag = `v${releaseVersion}`;
26+
const isGaRelease = version.isGa(releaseTag);
27+
28+
const tags = await git.getTags();
29+
if (!tags.includes(releaseTag)) {
30+
throw new Error(`The release tag ${releaseTag} was not found. Is this release tagged?`);
31+
}
32+
33+
// finds the first tag that is lower than releaseTag
34+
const previousTag = tags
35+
.filter((t) => t.startsWith('v') && semver.valid(t))
36+
.filter((t) => isGaRelease ? version.isGa(t) : true) // if is GA only consider other GAs
37+
.sort(semver.compare)
38+
.reverse()
39+
.find((t) => semver.lt(t, releaseTag));
40+
2341
cli.info('');
2442
cli.info(`Changes from ${chalk.bold(previousTag)}:`);
2543

release/commands.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
const { cli } = require('cli-ux');
33
const chalk = require('chalk');
44
const pkgUp = require('pkg-up');
5-
const semver = require('semver');
65

76
const branch = require('./branch');
87
const bump = require('./bump');
@@ -150,23 +149,7 @@ async function releaseCheckout(versionLike) {
150149
async function releaseChangelog() {
151150
await getValidReleaseBranch();
152151
const releaseVersion = await getPackageJsonVersion();
153-
const tags = await git.getTags();
154-
const releaseTag = `v${releaseVersion}`;
155-
const isGaRelease = version.isGa(releaseTag);
156-
157-
if (!tags.includes(releaseTag)) {
158-
throw new Error(`The release tag ${releaseTag} was not found. Is this release tagged?`);
159-
}
160-
161-
// finds the first tag that is lower than releaseTag
162-
const previousTag = tags
163-
.filter((t) => t.startsWith('v') && semver.valid(t))
164-
.filter((t) => isGaRelease ? version.isGa(t) : true) // if is GA only consider other GAs
165-
.sort(semver.compare)
166-
.reverse()
167-
.find((t) => semver.lt(t, releaseTag));
168-
169-
await changelog.render(previousTag, releaseTag);
152+
await changelog.render(releaseVersion);
170153
}
171154

172155
async function releasePublish() {
@@ -197,7 +180,8 @@ async function releasePublish() {
197180

198181
await publishRelease(releaseVersion, {
199182
downloadCenter: createDownloadCenter(),
200-
github
183+
github,
184+
changelog
201185
});
202186
}
203187

release/github.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
/* eslint-disable camelcase */
22
const { Octokit } = require('@octokit/rest');
3-
const wait = require('./wait');
43

54
const REPO = {
65
owner: 'mongodb-js',
76
repo: 'compass'
87
};
98

10-
// NOTE: github has a rate limit for unauthenticated
11-
// request of 60 per hour:
12-
const WAIT_OPTIONS = { delay: 5 /* minutes */ * 60 * 1000 };
139

1410
async function getRelease(tagOrVersion) {
1511
const tag = tagOrVersion.startsWith('v') ? tagOrVersion : `v${tagOrVersion}`;
@@ -21,12 +17,12 @@ async function getRelease(tagOrVersion) {
2117
return releases.find(({ tag_name }) => tag_name === tag);
2218
}
2319

24-
async function waitForReleasePublished(tagOrVersion) {
25-
return await wait(
26-
() => getRelease(tagOrVersion).then((release) => release && !release.draft),
27-
WAIT_OPTIONS
28-
);
20+
async function isReleasePublished(tagOrVersion) {
21+
// NOTE: github has a rate limit for unauthenticated
22+
// request of 60 per hour
23+
const release = await getRelease(tagOrVersion);
24+
return release && !release.draft;
2925
}
3026

31-
module.exports = { waitForReleasePublished };
27+
module.exports = { isReleasePublished };
3228

release/publish.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const version = require('./version');
66
const ux = require('./ux');
77

88
module.exports = async function publish(
9-
releaseVersion, { downloadCenter, github }
9+
releaseVersion, { downloadCenter, github, changelog }
1010
) {
1111
await uploadConfigIfNewer(releaseVersion, { downloadCenter });
12-
await waitGithubRelease(releaseVersion, { github });
12+
await waitGithubRelease(releaseVersion, { github, changelog });
1313

1414
cli.info(
1515
'\n',
@@ -40,19 +40,30 @@ async function uploadConfigIfNewer(
4040
cli.action.stop();
4141
}
4242

43-
async function waitGithubRelease(releaseVersion, { github }) {
43+
async function waitGithubRelease(releaseVersion, { github, changelog }) {
44+
cli.info('\n' + ux.separator(`👇 CHANGELOG FOR ${releaseVersion}`));
45+
await changelog.render(releaseVersion);
46+
cli.info('\n' + ux.separator('👆 CHANGELOG'), '\n');
47+
4448
cli.info(
4549
'\n',
4650
ux.manualAction(
4751
'Make sure the release is published on Github: ',
4852
ux.link('https://github.com/mongodb-js/compass/releases'), '\n\n',
49-
'You can run ', ux.command('npm run release changelog'), ' to get the release notes.', '\n\n',
53+
'Copy the changelog from above and put it into the description of the release.', '\n\n',
5054
chalk.bold('NOTE:'), ' if a release is not published on Github the Compass auto-update will not pick that up.',
5155
),
5256
'\n'
5357
);
5458

55-
cli.action.start(`Waiting for Github release ${chalk.bold(releaseVersion)} to be published.`);
56-
await github.waitForReleasePublished(releaseVersion);
59+
cli.info('Press enter when you have published the Github release...');
60+
ux.waitForEnter();
61+
62+
cli.action.start(`Checking if Github release ${chalk.bold(releaseVersion)} really is published.`);
63+
const alreadyPublished = await github.isReleasePublished(releaseVersion);
64+
if (!alreadyPublished) {
65+
cli.error('Release is not published yet - did you really publish?');
66+
cli.info('Please publish the release on Github and run publish again to verify it worked.');
67+
}
5768
cli.action.stop();
5869
}

release/publish.spec.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const publish = require('./publish');
1414

1515
describe('publish', () => {
1616
let deps;
17+
const isTty = process.stdin.isTTY;
18+
1719
beforeEach(async() => {
1820
const downloadCenterConfig = await fs.readJSON(
1921
path.resolve(__dirname, 'fixtures', 'config.json')
@@ -25,15 +27,24 @@ describe('publish', () => {
2527
downloadCenter.uploadConfig = sinon.mock().resolves();
2628

2729
const github = {
28-
waitForReleasePublished: sinon.mock().resolves({
29-
draft: true
30-
})
30+
isReleasePublished: sinon.mock().resolves(true)
31+
};
32+
33+
const changelog = {
34+
render: sinon.mock().resolves()
3135
};
3236

3337
deps = {
3438
downloadCenter,
35-
github
39+
github,
40+
changelog
3641
};
42+
43+
process.stdin.isTTY = false;
44+
});
45+
46+
afterEach(() => {
47+
process.stdin.isTTY = isTty;
3748
});
3849

3950
it('skips upload if release version is same as download center', async() => {
@@ -54,16 +65,4 @@ describe('publish', () => {
5465
await (publish('1.23.0', deps));
5566
expect(deps.downloadCenter.uploadConfig).to.have.been.calledWith(expected);
5667
});
57-
58-
it('waits for a the github release to be published', async() => {
59-
const error = await (publish('1.23.0', {
60-
...deps,
61-
github: {
62-
...deps.github,
63-
waitForReleasePublished: () => { throw new Error('maxWaitTime reached.'); }
64-
}
65-
})).catch(e => e);
66-
67-
expect(error.message).to.equal('maxWaitTime reached.');
68-
});
6968
});

release/ux.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
const execa = require('execa');
22
const chalk = require('chalk');
33

4+
function separator(message) {
5+
return chalk.yellow(
6+
chalk.bold(message)
7+
);
8+
}
9+
410
function manualAction(...message) {
511
return [
612
'👉\t',
7-
chalk.yellow(
8-
chalk.bold('MANUAL ACTION REQUIRED!: ')
9-
),
13+
separator('MANUAL ACTION REQUIRED!: '),
1014
'\n',
1115
...message.join('').split('\n').map((m) => `\t${m}`).join('\n')
1216
].join('');
@@ -29,6 +33,7 @@ function waitForEnter() {
2933
}
3034

3135
module.exports = {
36+
separator,
3237
manualAction,
3338
link,
3439
command,

0 commit comments

Comments
 (0)