Skip to content

Commit af88980

Browse files
rose-maddaleax
andauthored
chore(build): streamline release command execution MONGOSH-534 (#651)
Co-authored-by: Anna Henningsen <[email protected]>
1 parent 6287fd4 commit af88980

File tree

9 files changed

+52
-58
lines changed

9 files changed

+52
-58
lines changed

.evergreen/package-and-upload-artifact.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ set -e
44
cat <<RELEASE_MONGOSH > ~/release_mongosh.sh
55
set -e
66
cd $(pwd)
7+
78
export NODE_JS_VERSION=${NODE_JS_VERSION}
8-
export ARTIFACT_URL_FILE=artifact-url.txt
9+
export ARTIFACT_URL_FILE="$PWD/artifact-url.txt"
10+
911
source .evergreen/.setup_env
1012
tar xvzf dist.tgz
1113
dist/mongosh --version
14+
1215
if [ "$(uname)" == Linux ]; then
1316
# For the rpm, we want to download the RHEL/CentOS 7 mongocryptd binary.
1417
# (We can/should probably remove this after https://jira.mongodb.org/browse/MONGOSH-541)
@@ -27,7 +30,7 @@ if [ "$(uname)" == Linux ]; then
2730
-e EVERGREEN_EXPANSIONS_PATH=/tmp/build/tmp/expansions.yaml \
2831
-e NODE_JS_VERSION \
2932
-e BUILD_VARIANT \
30-
-e ARTIFACT_URL_FILE \
33+
-e ARTIFACT_URL_FILE="/tmp/build/artifact-url.txt" \
3134
-e DISTRO_ID_OVERRIDE \
3235
--rm -v $PWD:/tmp/build --network host centos7-package \
3336
-c 'cd /tmp/build && npm run evergreen-release package && npm run evergreen-release upload'
@@ -37,6 +40,10 @@ else
3740
# Verify signing
3841
spctl -a -vvv -t install dist/mongosh
3942
fi
43+
if [ "$OS" == "Windows_NT" ]; then
44+
# Fix absolute path before handing over to node
45+
export ARTIFACT_URL_FILE="\$(cygpath -w "\$ARTIFACT_URL_FILE")"
46+
fi
4047
npm run evergreen-release upload
4148
fi
4249
RELEASE_MONGOSH

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
"start": "npm run start-cli",
4747
"compile-exec": "npm run evergreen-release compile",
4848
"compile-all": "npm run compile-compass && npm run compile-exec",
49-
"preevergreen-release": "npm run compile-ts",
50-
"evergreen-release": "node scripts/evergreen-release.js",
49+
"evergreen-release": "cd packages/build && npm run evergreen-release --",
5150
"report-missing-help": "lerna run --stream --scope @mongosh/shell-api report-missing-help",
5251
"report-supported-api": "lerna run --stream --scope @mongosh/shell-api report-supported-api",
5352
"report-coverage": "nyc report --reporter=text --reporter=html && nyc check-coverage --lines=95",

packages/build/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 30000 --colors -r ts-node/register \"./src/**/*.spec.ts\"",
1919
"test-ci": "mocha -r \"../../scripts/import-expansions.js\" --timeout 30000 -r ts-node/register \"./src/**/*.spec.ts\"",
2020
"lint": "eslint \"**/*.{js,ts,tsx}\"",
21-
"check": "npm run lint"
21+
"check": "npm run lint",
22+
"evergreen-release": "ts-node -r ../../scripts/import-expansions.js src/index.ts"
2223
},
2324
"license": "Apache-2.0",
2425
"publishConfig": {

packages/build/src/index.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,36 @@
1-
import release from './release';
2-
import { getArtifactUrl } from './evergreen';
3-
import { downloadMongoDb } from './download-mongodb';
1+
import path from 'path';
42
import { BuildVariant } from './config';
3+
import { downloadMongoDb } from './download-mongodb';
4+
import { getArtifactUrl } from './evergreen';
5+
import { release, ReleaseCommand } from './release';
6+
7+
export { getArtifactUrl, downloadMongoDb };
8+
9+
if (require.main === module) {
10+
(async() => {
11+
const config = require(path.join(__dirname, '..', '..', '..', 'config', 'build.conf.js'));
12+
13+
const command = process.argv[2];
14+
15+
if (!['bump', 'compile', 'package', 'upload', 'draft', 'publish'].includes(command)) {
16+
throw new Error('USAGE: npm run evergreen-release <bump|compile|package|upload|draft|publish>');
17+
}
18+
19+
const cliBuildVariant = process.argv
20+
.map((arg) => arg.match(/^--build-variant=(.+)$/))
21+
.filter(Boolean)[0];
22+
if (cliBuildVariant) {
23+
config.buildVariant = cliBuildVariant[1];
24+
}
25+
26+
// Resolve 'Windows' to 'win32' etc.
27+
if (config.buildVariant in BuildVariant) {
28+
config.buildVariant = (BuildVariant as any)[config.buildVariant];
29+
}
530

6-
export default release;
7-
export { release, BuildVariant, getArtifactUrl, downloadMongoDb };
31+
await release(command as ReleaseCommand, config);
32+
})().then(
33+
() => process.exit(0),
34+
(err) => process.nextTick(() => { throw err; })
35+
);
36+
}

packages/build/src/release.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import { runDraft } from './run-draft';
1515
import { runPublish } from './run-publish';
1616
import { runUpload } from './run-upload';
1717

18+
export type ReleaseCommand = 'bump' | 'compile' | 'package' | 'upload' | 'draft' | 'publish';
19+
1820
/**
1921
* Run release specific commands.
2022
* @param command The command to run
2123
* @param config The configuration, usually config/build.config.js.
2224
*/
23-
export default async function release(
24-
command: 'bump' | 'compile' | 'package' | 'upload' | 'draft' | 'publish',
25+
export async function release(
26+
command: ReleaseCommand,
2527
config: Config
2628
): Promise<void> {
2729
config = {

packages/build/src/run-draft.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { promises as fs } from 'fs';
22
import path from 'path';
3-
import { ALL_BUILD_VARIANTS, Config, getReleaseVersionFromTag, redactConfig } from './config';
3+
import { ALL_BUILD_VARIANTS, Config, getReleaseVersionFromTag } from './config';
44
import { uploadArtifactToDownloadCenter as uploadArtifactToDownloadCenterFn } from './download-center';
55
import { downloadArtifactFromEvergreen as downloadArtifactFromEvergreenFn } from './evergreen';
66
import { GithubRepo } from './github-repo';
@@ -12,11 +12,6 @@ export async function runDraft(
1212
uploadToDownloadCenter: typeof uploadArtifactToDownloadCenterFn = uploadArtifactToDownloadCenterFn,
1313
downloadArtifactFromEvergreen: typeof downloadArtifactFromEvergreenFn = downloadArtifactFromEvergreenFn
1414
): Promise<void> {
15-
console.info(
16-
'mongosh: beginning draft release with config:',
17-
redactConfig(config)
18-
);
19-
2015
if (!config.triggeringGitTag || !getReleaseVersionFromTag(config.triggeringGitTag)) {
2116
console.error('mongosh: skipping draft as not triggered by a git tag that matches a draft/release tag');
2217
return;

packages/build/src/run-publish.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
BuildVariant,
55
Config,
66
getReleaseVersionFromTag,
7-
redactConfig,
87
shouldDoPublicRelease as shouldDoPublicReleaseFn
98
} from './config';
109
import { createAndPublishDownloadCenterConfig as createAndPublishDownloadCenterConfigFn } from './download-center';
@@ -26,11 +25,6 @@ export async function runPublish(
2625
shouldDoPublicRelease: typeof shouldDoPublicReleaseFn = shouldDoPublicReleaseFn,
2726
getEvergreenArtifactUrl: typeof getArtifactUrlFn = getArtifactUrlFn
2827
): Promise<void> {
29-
console.info(
30-
'mongosh: beginning publish release with config:',
31-
redactConfig(config)
32-
);
33-
3428
if (!shouldDoPublicRelease(config)) {
3529
console.warn('mongosh: Not triggering publish - configuration does not match a public release!');
3630
return;

packages/cli-repl/src/smoke-tests-fle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const assert = function(value, message) {
1313
try {
1414
// The mongocryptd binary that we ship works on Ubuntu 18.04 and above,
1515
// but not Ubuntu 16.04.
16-
if (fs.readFileSync('/etc/issue', 'utf8').match(/Ubuntu 16/)) {
16+
if (os.platform() === 'linux' && fs.readFileSync('/etc/issue', 'utf8').match(/Ubuntu 16/)) {
1717
print('Test skipped')
1818
process.exit(0);
1919
}

scripts/evergreen-release.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)