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
11 changes: 9 additions & 2 deletions .evergreen/package-and-upload-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ set -e
cat <<RELEASE_MONGOSH > ~/release_mongosh.sh
set -e
cd $(pwd)

export NODE_JS_VERSION=${NODE_JS_VERSION}
export ARTIFACT_URL_FILE=artifact-url.txt
export ARTIFACT_URL_FILE="$PWD/artifact-url.txt"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use absolute paths on Windows, you’ll need to use cygpath -w on the filepath before passing it to Node.js (because this would be /cygdrive/c/.../artifact-url.txt, which on Windows would be interpreted as a path relative to the FS root, e.g. C:\cygdrive\c\...\artifact-url.txt)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope the way I've included it now makes that part work...


source .evergreen/.setup_env
tar xvzf dist.tgz
dist/mongosh --version

if [ "$(uname)" == Linux ]; then
# For the rpm, we want to download the RHEL/CentOS 7 mongocryptd binary.
# (We can/should probably remove this after https://jira.mongodb.org/browse/MONGOSH-541)
Expand All @@ -27,7 +30,7 @@ if [ "$(uname)" == Linux ]; then
-e EVERGREEN_EXPANSIONS_PATH=/tmp/build/tmp/expansions.yaml \
-e NODE_JS_VERSION \
-e BUILD_VARIANT \
-e ARTIFACT_URL_FILE \
-e ARTIFACT_URL_FILE="/tmp/build/artifact-url.txt" \
-e DISTRO_ID_OVERRIDE \
--rm -v $PWD:/tmp/build --network host centos7-package \
-c 'cd /tmp/build && npm run evergreen-release package && npm run evergreen-release upload'
Expand All @@ -37,6 +40,10 @@ else
# Verify signing
spctl -a -vvv -t install dist/mongosh
fi
if [ "$OS" == "Windows_NT" ]; then
# Fix absolute path before handing over to node
export ARTIFACT_URL_FILE="\$(cygpath -w "\$ARTIFACT_URL_FILE")"
fi
npm run evergreen-release upload
fi
RELEASE_MONGOSH
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"start": "npm run start-cli",
"compile-exec": "npm run evergreen-release compile",
"compile-all": "npm run compile-compass && npm run compile-exec",
"preevergreen-release": "npm run compile-ts",
"evergreen-release": "node scripts/evergreen-release.js",
"evergreen-release": "cd packages/build && npm run evergreen-release --",
"report-missing-help": "lerna run --stream --scope @mongosh/shell-api report-missing-help",
"report-supported-api": "lerna run --stream --scope @mongosh/shell-api report-supported-api",
"report-coverage": "nyc report --reporter=text --reporter=html && nyc check-coverage --lines=95",
Expand Down
3 changes: 2 additions & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 30000 --colors -r ts-node/register \"./src/**/*.spec.ts\"",
"test-ci": "mocha -r \"../../scripts/import-expansions.js\" --timeout 30000 -r ts-node/register \"./src/**/*.spec.ts\"",
"lint": "eslint \"**/*.{js,ts,tsx}\"",
"check": "npm run lint"
"check": "npm run lint",
"evergreen-release": "ts-node -r ../../scripts/import-expansions.js src/index.ts"
},
"license": "Apache-2.0",
"publishConfig": {
Expand Down
39 changes: 34 additions & 5 deletions packages/build/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
import release from './release';
import { getArtifactUrl } from './evergreen';
import { downloadMongoDb } from './download-mongodb';
import path from 'path';
import { BuildVariant } from './config';
import { downloadMongoDb } from './download-mongodb';
import { getArtifactUrl } from './evergreen';
import { release, ReleaseCommand } from './release';

export { getArtifactUrl, downloadMongoDb };

if (require.main === module) {
(async() => {
const config = require(path.join(__dirname, '..', '..', '..', 'config', 'build.conf.js'));

const command = process.argv[2];

if (!['bump', 'compile', 'package', 'upload', 'draft', 'publish'].includes(command)) {
throw new Error('USAGE: npm run evergreen-release <bump|compile|package|upload|draft|publish>');
}

const cliBuildVariant = process.argv
.map((arg) => arg.match(/^--build-variant=(.+)$/))
.filter(Boolean)[0];
if (cliBuildVariant) {
config.buildVariant = cliBuildVariant[1];
}

// Resolve 'Windows' to 'win32' etc.
if (config.buildVariant in BuildVariant) {
config.buildVariant = (BuildVariant as any)[config.buildVariant];
}

export default release;
export { release, BuildVariant, getArtifactUrl, downloadMongoDb };
await release(command as ReleaseCommand, config);
})().then(
() => process.exit(0),
(err) => process.nextTick(() => { throw err; })
);
}
6 changes: 4 additions & 2 deletions packages/build/src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { runDraft } from './run-draft';
import { runPublish } from './run-publish';
import { runUpload } from './run-upload';

export type ReleaseCommand = 'bump' | 'compile' | 'package' | 'upload' | 'draft' | 'publish';

/**
* Run release specific commands.
* @param command The command to run
* @param config The configuration, usually config/build.config.js.
*/
export default async function release(
command: 'bump' | 'compile' | 'package' | 'upload' | 'draft' | 'publish',
export async function release(
command: ReleaseCommand,
config: Config
): Promise<void> {
config = {
Expand Down
7 changes: 1 addition & 6 deletions packages/build/src/run-draft.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promises as fs } from 'fs';
import path from 'path';
import { ALL_BUILD_VARIANTS, Config, getReleaseVersionFromTag, redactConfig } from './config';
import { ALL_BUILD_VARIANTS, Config, getReleaseVersionFromTag } from './config';
import { uploadArtifactToDownloadCenter as uploadArtifactToDownloadCenterFn } from './download-center';
import { downloadArtifactFromEvergreen as downloadArtifactFromEvergreenFn } from './evergreen';
import { GithubRepo } from './github-repo';
Expand All @@ -12,11 +12,6 @@ export async function runDraft(
uploadToDownloadCenter: typeof uploadArtifactToDownloadCenterFn = uploadArtifactToDownloadCenterFn,
downloadArtifactFromEvergreen: typeof downloadArtifactFromEvergreenFn = downloadArtifactFromEvergreenFn
): Promise<void> {
console.info(
'mongosh: beginning draft release with config:',
redactConfig(config)
);

if (!config.triggeringGitTag || !getReleaseVersionFromTag(config.triggeringGitTag)) {
console.error('mongosh: skipping draft as not triggered by a git tag that matches a draft/release tag');
return;
Expand Down
6 changes: 0 additions & 6 deletions packages/build/src/run-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
BuildVariant,
Config,
getReleaseVersionFromTag,
redactConfig,
shouldDoPublicRelease as shouldDoPublicReleaseFn
} from './config';
import { createAndPublishDownloadCenterConfig as createAndPublishDownloadCenterConfigFn } from './download-center';
Expand All @@ -26,11 +25,6 @@ export async function runPublish(
shouldDoPublicRelease: typeof shouldDoPublicReleaseFn = shouldDoPublicReleaseFn,
getEvergreenArtifactUrl: typeof getArtifactUrlFn = getArtifactUrlFn
): Promise<void> {
console.info(
'mongosh: beginning publish release with config:',
redactConfig(config)
);

if (!shouldDoPublicRelease(config)) {
console.warn('mongosh: Not triggering publish - configuration does not match a public release!');
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-repl/src/smoke-tests-fle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const assert = function(value, message) {
try {
// The mongocryptd binary that we ship works on Ubuntu 18.04 and above,
// but not Ubuntu 16.04.
if (fs.readFileSync('/etc/issue', 'utf8').match(/Ubuntu 16/)) {
if (os.platform() === 'linux' && fs.readFileSync('/etc/issue', 'utf8').match(/Ubuntu 16/)) {
print('Test skipped')
process.exit(0);
}
Expand Down
33 changes: 0 additions & 33 deletions scripts/evergreen-release.js

This file was deleted.