Skip to content

Commit c73bde5

Browse files
committed
testing
1 parent 8a1dd88 commit c73bde5

File tree

8 files changed

+96
-2
lines changed

8 files changed

+96
-2
lines changed

.evergreen.yml

+13
Original file line numberDiff line numberDiff line change
@@ -4295,10 +4295,17 @@ functions:
42954295
params:
42964296
file: tmp/expansions.yaml
42974297
redacted: true
4298+
- command: ec2.assume_role
4299+
params:
4300+
role_arn: "arn:aws:iam::119629040606:role/s3-access.cdn-origin-compass"
42984301
- command: shell.exec
42994302
params:
43004303
working_dir: src
43014304
shell: bash
4305+
env:
4306+
DOWNLOAD_CENTER_AWS_KEY_NEW: ${AWS_ACCESS_KEY_ID}
4307+
DOWNLOAD_CENTER_AWS_SECRET_NEW: ${AWS_SECRET_ACCESS_KEY}
4308+
DOWNLOAD_CENTER_AWS_SESSION_TOKEN_NEW: ${AWS_SESSION_TOKEN}
43024309
script: |
43034310
set -e
43044311
{
@@ -4362,6 +4369,9 @@ functions:
43624369
params:
43634370
file: tmp/expansions.yaml
43644371
redacted: true
4372+
- command: ec2.assume_role
4373+
params:
4374+
role_arn: "arn:aws:iam::119629040606:role/s3-access.cdn-origin-compass"
43654375
- command: shell.exec
43664376
# silent: true
43674377
params:
@@ -4370,6 +4380,9 @@ functions:
43704380
env:
43714381
devtoolsbot_npm_token: ${devtoolsbot_npm_token}
43724382
node_js_version: ${node_js_version}
4383+
DOWNLOAD_CENTER_AWS_KEY_NEW: ${AWS_ACCESS_KEY_ID}
4384+
DOWNLOAD_CENTER_AWS_SECRET_NEW: ${AWS_SECRET_ACCESS_KEY}
4385+
DOWNLOAD_CENTER_AWS_SESSION_TOKEN_NEW: ${AWS_SESSION_TOKEN}
43734386
script: |
43744387
set -e
43754388
export PUPPETEER_SKIP_DOWNLOAD="true"

config/build.conf.js

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ module.exports = {
9797
evgAwsSecret: process.env.AWS_SECRET,
9898
downloadCenterAwsKey: process.env.DOWNLOAD_CENTER_AWS_KEY,
9999
downloadCenterAwsSecret: process.env.DOWNLOAD_CENTER_AWS_SECRET,
100+
downloadCenterAwsKeyNew: process.env.DOWNLOAD_CENTER_AWS_KEY_NEW,
101+
downloadCenterAwsSecretNew: process.env.DOWNLOAD_CENTER_AWS_SECRET_NEW,
102+
downloadCenterAwsSessionTokenNew: process.env.DOWNLOAD_CENTER_AWS_SESSION_TOKEN_NEW,
100103
injectedJsonFeedFile: path.join(ROOT, 'config', 'mongosh-versions.json'),
101104
githubToken: process.env.GITHUB_TOKEN,
102105
segmentKey: process.env.SEGMENT_API_KEY,

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

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { DownloadCenter as DownloadCenterCls } from '@mongodb-js/dl-center';
22
import * as fs from 'fs';
33
import path from 'path';
4-
import { ARTIFACTS_BUCKET, ARTIFACTS_FOLDER } from './constants';
4+
import {
5+
ARTIFACTS_BUCKET,
6+
ARTIFACTS_BUCKET_NEW,
7+
ARTIFACTS_FOLDER,
8+
} from './constants';
59

610
export async function uploadArtifactToDownloadCenter(
711
filePath: string,
@@ -20,3 +24,23 @@ export async function uploadArtifactToDownloadCenter(
2024
fs.createReadStream(filePath)
2125
);
2226
}
27+
28+
export async function uploadArtifactToDownloadCenterNew(
29+
filePath: string,
30+
awsAccessKeyId: string,
31+
awsSecretAccessKey: string,
32+
awsSessionToken: string,
33+
DownloadCenter: typeof DownloadCenterCls = DownloadCenterCls
34+
): Promise<void> {
35+
const dlcenter = new DownloadCenter({
36+
bucket: ARTIFACTS_BUCKET_NEW,
37+
accessKeyId: awsAccessKeyId,
38+
secretAccessKey: awsSecretAccessKey,
39+
sessionToken: awsSessionToken,
40+
});
41+
42+
await dlcenter.uploadAsset(
43+
`${ARTIFACTS_FOLDER}/${path.basename(filePath)}`,
44+
fs.createReadStream(filePath)
45+
);
46+
}

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

+30
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
} from '@mongodb-js/dl-center/dist/download-center-config';
1010
import {
1111
ARTIFACTS_BUCKET,
12+
ARTIFACTS_BUCKET_NEW,
1213
JSON_FEED_ARTIFACT_KEY,
1314
ARTIFACTS_URL_PUBLIC_BASE,
1415
CONFIGURATION_KEY,
@@ -55,6 +56,9 @@ export async function createAndPublishDownloadCenterConfig(
5556
packageInformation: PackageInformationProvider,
5657
awsAccessKeyId: string,
5758
awsSecretAccessKey: string,
59+
awsAccessKeyIdNew: string,
60+
awsSecretAccessKeyNew: string,
61+
awsSessionTokenNew: string,
5862
injectedJsonFeedFile: string,
5963
isDryRun: boolean,
6064
ctaConfig: CTAConfig,
@@ -100,6 +104,13 @@ export async function createAndPublishDownloadCenterConfig(
100104
secretAccessKey: awsSecretAccessKey,
101105
});
102106

107+
const dlcenterArtifactsNew = new DownloadCenter({
108+
bucket: ARTIFACTS_BUCKET_NEW,
109+
accessKeyId: awsAccessKeyIdNew,
110+
secretAccessKey: awsSecretAccessKeyNew,
111+
sessionToken: awsSessionTokenNew,
112+
});
113+
103114
const existingJsonFeed = await getCurrentJsonFeed(dlcenterArtifacts);
104115
const injectedJsonFeed: JsonFeed | undefined = injectedJsonFeedFile
105116
? JSON.parse(await fs.readFile(injectedJsonFeedFile, 'utf8'))
@@ -135,12 +146,20 @@ export async function createAndPublishDownloadCenterConfig(
135146
JSON.stringify(newJsonFeed, null, 2)
136147
),
137148
]);
149+
150+
await dlcenterArtifactsNew.uploadAsset(
151+
JSON_FEED_ARTIFACT_KEY,
152+
JSON.stringify(newJsonFeed, null, 2)
153+
);
138154
}
139155

140156
export async function updateJsonFeedCTA(
141157
config: CTAConfig,
142158
awsAccessKeyId: string,
143159
awsSecretAccessKey: string,
160+
awsAccessKeyIdNew: string,
161+
awsSecretAccessKeyNew: string,
162+
awsSessionTokenNew: string,
144163
isDryRun: boolean,
145164
DownloadCenter: typeof DownloadCenterCls = DownloadCenterCls
146165
) {
@@ -150,6 +169,13 @@ export async function updateJsonFeedCTA(
150169
secretAccessKey: awsSecretAccessKey,
151170
});
152171

172+
const dlcenterArtifactsNew = new DownloadCenter({
173+
bucket: ARTIFACTS_BUCKET_NEW,
174+
accessKeyId: awsAccessKeyIdNew,
175+
secretAccessKey: awsSecretAccessKeyNew,
176+
sessionToken: awsSessionTokenNew,
177+
});
178+
153179
const jsonFeed = await getCurrentJsonFeed(dlcenterArtifacts);
154180
if (!jsonFeed) {
155181
throw new Error('No existing JSON feed found');
@@ -165,6 +191,10 @@ export async function updateJsonFeedCTA(
165191
}
166192

167193
await dlcenterArtifacts.uploadAsset(JSON_FEED_ARTIFACT_KEY, patchedJsonFeed);
194+
await dlcenterArtifactsNew.uploadAsset(
195+
JSON_FEED_ARTIFACT_KEY,
196+
patchedJsonFeed
197+
);
168198
}
169199

170200
function populateJsonFeedCTAs(jsonFeed: JsonFeed, ctas: CTAConfig) {

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

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export const CONFIGURATION_KEY =
1616
*/
1717
export const ARTIFACTS_BUCKET = 'downloads.10gen.com';
1818

19+
/**
20+
* The S3 bucket for download center artifacts.
21+
*/
22+
export const ARTIFACTS_BUCKET_NEW = 'cdn-origin-compass';
23+
1924
/**
2025
* The S3 "folder" for uploaded artifacts.
2126
*/

packages/build/src/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ if (require.main === module) {
8181
ctaConfig,
8282
downloadCenterAwsKey,
8383
downloadCenterAwsSecret,
84+
downloadCenterAwsKeyNew,
85+
downloadCenterAwsSecretNew,
86+
downloadCenterAwsSessionTokenNew,
8487
isDryRun,
8588
} = getBuildConfig();
8689

@@ -92,6 +95,9 @@ if (require.main === module) {
9295
ctaConfig,
9396
downloadCenterAwsKey,
9497
downloadCenterAwsSecret,
98+
downloadCenterAwsKeyNew,
99+
downloadCenterAwsSecretNew,
100+
downloadCenterAwsSessionTokenNew,
95101
!!isDryRun
96102
);
97103
break;

packages/build/src/release.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { Octokit } from '@octokit/rest';
22
import { runCompile } from './compile';
33
import type { Config } from './config';
44
import { getReleaseVersionFromTag, redactConfig } from './config';
5-
import { uploadArtifactToDownloadCenter } from './download-center';
5+
import {
6+
uploadArtifactToDownloadCenter,
7+
uploadArtifactToDownloadCenterNew,
8+
} from './download-center';
69
import {
710
downloadArtifactFromEvergreen,
811
uploadArtifactToEvergreen,
@@ -95,6 +98,7 @@ export async function release(
9598
githubRepo,
9699
new PackageBumper(),
97100
uploadArtifactToDownloadCenter,
101+
uploadArtifactToDownloadCenterNew,
98102
downloadArtifactFromEvergreen
99103
);
100104
} else if (command === 'download-and-list-artifacts') {

packages/build/src/run-draft.ts

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'path';
33
import type { Config } from './config';
44
import { ALL_PACKAGE_VARIANTS, getReleaseVersionFromTag } from './config';
55
import { uploadArtifactToDownloadCenter as uploadArtifactToDownloadCenterFn } from './download-center';
6+
import { uploadArtifactToDownloadCenterNew as uploadArtifactToDownloadCenterFnNew } from './download-center';
67
import { downloadArtifactFromEvergreen as downloadArtifactFromEvergreenFn } from './evergreen';
78
import { generateChangelog as generateChangelogFn } from './git';
89
import { getPackageFile } from './packaging';
@@ -14,6 +15,7 @@ export async function runDraft(
1415
githubRepo: GithubRepo,
1516
packageBumper: PackageBumper,
1617
uploadToDownloadCenter: typeof uploadArtifactToDownloadCenterFn = uploadArtifactToDownloadCenterFn,
18+
uploadToDownloadCenterNew: typeof uploadArtifactToDownloadCenterFnNew = uploadArtifactToDownloadCenterFnNew,
1719
downloadArtifactFromEvergreen: typeof downloadArtifactFromEvergreenFn = downloadArtifactFromEvergreenFn,
1820
ensureGithubReleaseExistsAndUpdateChangelog: typeof ensureGithubReleaseExistsAndUpdateChangelogFn = ensureGithubReleaseExistsAndUpdateChangelogFn
1921
): Promise<void> {
@@ -88,6 +90,13 @@ export async function runDraft(
8890
contentType,
8991
}),
9092
]);
93+
94+
await uploadToDownloadCenterNew(
95+
downloadedArtifact,
96+
config.downloadCenterAwsKeyNew as string,
97+
config.downloadCenterAwsSecretNew as string,
98+
config.downloadCenterAwsSessionTokenNew as string
99+
);
91100
})
92101
);
93102
}

0 commit comments

Comments
 (0)