Skip to content

Commit b156073

Browse files
committed
Do s3 uploading via build module
1 parent d39e195 commit b156073

File tree

7 files changed

+28
-54
lines changed

7 files changed

+28
-54
lines changed

.evergreen.yml

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
11
# Variables for common functions.
22
#
3-
# upload_file: Saves a file to the Evergreen S3 bucket.
4-
# upload_download_center: Upload a file to the download center S3 bucket.
53
# compile_and_release: Runs the exec compile and release process.
64
variables:
7-
- &upload_file
8-
command: s3.put
9-
params:
10-
aws_key: ${aws_key}
11-
aws_secret: ${aws_secret}
12-
bucket: mciuploads
13-
permissions: public-read
14-
content_type: application/octet-stream
15-
- &upload_download_center
16-
command: s3.put
17-
params:
18-
aws_key: ${download_center_aws_key}
19-
aws_secret: ${download_center_aws_secret}
20-
bucket: info-mongodb-com
21-
permissions: public-read
22-
content_type: application/octet-stream
235
- &compile_and_release
246
command: shell.exec
257
params:
@@ -29,6 +11,8 @@ variables:
2911
source .evergreen/.setup_env
3012
export SEGMENT_API_KEY=${segment_key}
3113
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
14+
export PROJECT=${project}
15+
export REVISION=${revision}
3216
export AWS_KEY=${aws_key}
3317
export AWS_SECRET=${aws_secret}
3418
export DOWNLOAD_CENTER_AWS_KEY=${download_center_aws_key}
@@ -100,16 +84,6 @@ functions:
10084
shell: bash
10185
script: |
10286
echo "################# Sign, notarise, and release MacOS artifacts ################"
103-
- <<: *upload_file
104-
params:
105-
local_files_include_filter:
106-
- src/dist/*.*
107-
remote_file: ${project}/${revision}/
108-
- <<: *upload_download_center
109-
params:
110-
local_files_include_filter:
111-
- src/dist/mongosh.json
112-
remote_file: com-download-center/
11387
release_linux:
11488
- <<: *compile_and_release
11589
- command: shell.exec
@@ -118,11 +92,6 @@ functions:
11892
shell: bash
11993
script: |
12094
echo "################# Sign and release Linux artifacts ################"
121-
- <<: *upload_file
122-
params:
123-
local_files_include_filter:
124-
- src/dist/*.*
125-
remote_file: ${project}/${revision}/
12695
release_win:
12796
- <<: *compile_and_release
12897
- command: shell.exec
@@ -132,11 +101,6 @@ functions:
132101
script: |
133102
echo "################# Sign and release Windows artifacts ################"
134103
ls -la dist/
135-
- <<: *upload_file
136-
params:
137-
local_files_include_filter:
138-
- src/dist/*.*
139-
remote_file: ${project}/${revision}/
140104
# Tasks will show up as the individual blocks in the Evergreen UI that can
141105
# pass or fail.
142106
#

config/build.conf.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ module.exports = {
3232
version: CONFIG.version,
3333
input: INPUT,
3434
outputDir: OUTPUT_DIR,
35+
project: process.env.PROJECT,
36+
revision: process.env.REVISION,
3537
evgAwsKey: process.env.AWS_KEY,
3638
evgAwsSecret: process.env.AWS_SECRET,
3739
downloadCenterAwsKey: process.env.DOWNLOAD_CENTER_AWS_KEY,

packages/build/src/download-center.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,4 @@ describe('download center module', () => {
2323
expect(config).to.include('mongosh-1.2.2-win.zip');
2424
});
2525
});
26-
27-
describe('.uploadDownloadCenterConfig', () => {
28-
29-
});
3026
});

packages/build/src/download-center.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { promises as fs } from 'fs';
77
import handlebars from 'handlebars';
88
import S3 from 'aws-sdk/clients/s3';
99
<<<<<<< HEAD
10+
<<<<<<< HEAD
1011
import upload, { PUBLIC_READ } from './s3';
1112

1213
/**
@@ -29,6 +30,9 @@ import handlebars from 'handlebars';
2930
=======
3031
import upload from './s3';
3132
>>>>>>> Adding s3 uploading ability into build
33+
=======
34+
import upload, { PUBLIC_READ } from './s3';
35+
>>>>>>> Do s3 uploading via build module
3236

3337
/**
3438
* The filename in the download center.
@@ -45,11 +49,6 @@ const BUCKET = 'info-mongodb-com';
4549
*/
4650
const DIRECTORY = 'com-download-center';
4751

48-
/**
49-
* The default ACL.
50-
*/
51-
const PUBLIC_READ = 'public-read';
52-
5352
/**
5453
* The download center JSON template.
5554
*/

packages/build/src/release.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ import S3 from 'aws-sdk/clients/s3';
1313
*/
1414
const release = async(config: Config) => {
1515
const platform = os.platform();
16-
const evgS3 = new S3({
17-
accessKeyId: config.evgAwsKey,
18-
secretAccessKey: config.evgAwsSecret
19-
});
2016

2117
// 1. Build the executable.
2218
await compileExec(config.input, config.outputDir, platform);
2319

2420
// 2. Sign the executable for each OS.
2521

2622
// 3. Zip the executable.
27-
await zip(config.input, config.outputDir, platform, config.version);
23+
const artifact = await zip(config.input, config.outputDir, platform, config.version);
2824

2925
// 4. Create & sign the .deb (only on linux)
3026
// 5. Create & sign the .rpm (only on linux)
@@ -36,7 +32,15 @@ const release = async(config: Config) => {
3632
// 2. Publish the .rpm (only on linux)
3733
// 3. Create PR for Homebrew (only on macos)
3834

39-
// 4. Upload artifacts to S3 for Evergreen and downloads. (Handled in .evergreen.yml)
35+
// 4. Upload artifacts to S3 for Evergreen and downloads.
36+
// await uploadArtifactToEvergreen(
37+
// artifact,
38+
// config.evgAwsKey,
39+
// config.evgAwsSecret,
40+
// config.project,
41+
// config.revision
42+
// );
43+
// await uploadArtifactToDownloads();
4044

4145
// 5. Create Github release.
4246

packages/build/src/s3.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import S3 from 'aws-sdk/clients/s3';
22

3+
/**
4+
* The default ACL.
5+
*/
6+
const PUBLIC_READ = 'public-read';
7+
38
/**
49
* Takes a configured S3 instance and uploads its data.
510
*
@@ -21,3 +26,4 @@ const upload = (params: any, s3: any): Promise<any> => {
2126
};
2227

2328
export default upload;
29+
export { PUBLIC_READ };

packages/build/src/zip.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,18 @@ const zipWindows = async(input: string, filename: string) => {
5858
* @param {string} outputDir - Where to save the zip.
5959
* @param {string} platform - The platform.
6060
* @param {string} version - The version.
61+
*
62+
* @returns {string} The filename of the zip.
6163
*/
62-
const zip = async(input: string, outputDir: string, platform: string, version: string) => {
64+
const zip = async(input: string, outputDir: string, platform: string, version: string): string => {
6365
const filename = zipPath(outputDir, platform, version);
6466
console.log('mongosh: zipping:', filename);
6567
if (platform === Platform.Windows) {
6668
zipWindows(input, filename);
6769
} else {
6870
zipPosix(outputDir, filename);
6971
}
72+
return filename;
7073
};
7174

7275
export default zip;

0 commit comments

Comments
 (0)