Skip to content

Commit 784ce7c

Browse files
committed
Upload artifact to downloads.mongodb.com
1 parent 461bee3 commit 784ce7c

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

.evergreen.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ variables:
1717
export AWS_SECRET=${aws_secret}
1818
export DOWNLOAD_CENTER_AWS_KEY=${download_center_aws_key}
1919
export DOWNLOAD_CENTER_AWS_SECRET=${download_center_aws_secret}
20+
export DOWNLOADS_AWS_KEY=${downloads_aws_key}
21+
export DOWNLOADS_AWS_SECRET=${downloads_aws_secret}
2022
npm run release
2123
# Functions are any command that can be run.
2224
#

config/build.conf.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,7 @@ module.exports = {
3737
evgAwsKey: process.env.AWS_KEY,
3838
evgAwsSecret: process.env.AWS_SECRET,
3939
downloadCenterAwsKey: process.env.DOWNLOAD_CENTER_AWS_KEY,
40-
downloadCenterAwsSecret: process.env.DOWNLOAD_CENTER_AWS_SECRET
40+
downloadCenterAwsSecret: process.env.DOWNLOAD_CENTER_AWS_SECRET,
41+
downloadsAwsKey: process.env.DOWNLOADS_AWS_KEY,
42+
downloadsAwsSecret: process.env.DOWNLOADS_AWS_SECRET
4143
};

packages/build/src/release.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ const release = async(config: Config) => {
4141
config.project,
4242
config.revision
4343
);
44-
// await uploadArtifactToDownloads();
44+
await uploadArtifactToDownloads(
45+
artifact,
46+
config.downloadsAwsKey,
47+
config.downloadsAwsSecret,
48+
config.project,
49+
config.revision
50+
);
4551

4652
// 5. Create Github release.
4753

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import S3 from 'aws-sdk/clients/s3';
4+
import upload, { PUBLIC_READ } from './s3';
5+
6+
/**
7+
* The S3 bucket.
8+
*/
9+
const BUCKET = 'downloads.10gen.com';
10+
11+
/**
12+
* Upload the provided argument to evergreen s3 bucket.
13+
*
14+
* @param {string} artifact - The artifact.
15+
* @param {string} awsKey - The aws key.
16+
* @param {string} awsSecret - The aws secret.
17+
*
18+
* @returns {Promise} The promise.
19+
*/
20+
const uploadArtifactToDownloads = (artifact: string, awsKey: string, awsSecret: string, project: string, revision: string): Promise<any> => {
21+
const s3 = new S3({
22+
accessKeyId: awsKey,
23+
secretAccessKey: awsSecret
24+
});
25+
const uploadParams = {
26+
ACL: PUBLIC_READ,
27+
Bucket: BUCKET,
28+
Key: `/mongosh/${path.basename(artifact)}`,
29+
Body: fs.createReadStream(artifact)
30+
};
31+
console.log(`mongosh: uploading ${artifact} to downloads`);
32+
return upload(uploadParams, s3);
33+
};
34+
35+
export default uploadArtifactToDownloads;

0 commit comments

Comments
 (0)