Skip to content

Commit e575004

Browse files
authored
fix(ci): include releaser name in application artifacts COMPASS-7888 (#5921)
1 parent 4be36b4 commit e575004

File tree

7 files changed

+147
-24
lines changed

7 files changed

+147
-24
lines changed

.evergreen/compass_package.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,49 @@ npm run generate-first-party-deps-json
1616

1717
ls -la packages/compass/dist
1818
ls -la .sbom
19+
20+
get_compass_package_json_field() {
21+
node -p 'JSON.parse(fs.readFileSync("packages/compass/package.json"))['"'$1'"']'
22+
}
23+
24+
papertrail() {
25+
set +x
26+
echo "X-PAPERTRAIL-KEY-ID: ${PAPERTRAIL_KEY_ID}" > .papertrail.headers
27+
echo "X-PAPERTRAIL-SECRET-KEY: ${PAPERTRAIL_SECRET_KEY}" >> .papertrail.headers
28+
set -x
29+
30+
version=$(get_compass_package_json_field version)
31+
product="compass"
32+
if echo "$version" | grep -q -- -dev. ; then
33+
version+="${EVERGREEN_REVISION}_${EVERGREEN_REVISION_ORDER_ID}"
34+
product+="-dev"
35+
elif echo "$version" | grep -q -- -beta. ; then
36+
product+="-beta"
37+
fi
38+
build="${EVERGREEN_TASK_ID}_${EVERGREEN_EXECUTION}"
39+
platform="evergreen"
40+
submitter=$(get_compass_package_json_field releasePublisher)
41+
if [ $submitter = "null" ]; then
42+
submitter="${EVERGREEN_AUTHOR}"
43+
fi
44+
45+
for file in packages/compass/dist/* ; do
46+
if [ -f "$file" ]; then
47+
filename=$(basename "$file")
48+
checksum=$(shasum -a 256 "$file" | cut -f1 -d' ')
49+
50+
curl -G -X POST -H @.papertrail.headers "https://papertrail.devprod-infra.prod.corp.mongodb.com/trace" \
51+
--data-urlencode "version=${version}" \
52+
--data-urlencode "product=${product}" \
53+
--data-urlencode "sha256=${checksum}" \
54+
--data-urlencode "filename=${filename}" \
55+
--data-urlencode "build=${build}" \
56+
--data-urlencode "platform=${platform}" \
57+
--data-urlencode "submitter=${submitter}"
58+
fi
59+
done
60+
61+
rm -f .papertrail.headers
62+
}
63+
64+
papertrail

.evergreen/functions.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ functions:
304304
# Load environment variables
305305
eval $(.evergreen/print-compass-env.sh)
306306
# Generates and expansion file with build target metadata in packages/compass/expansions.yml
307-
npm run --workspace mongodb-compass build-info -- ${target_platform} ${target_arch} --format=yaml --flatten ${compass_distribution} --out expansions.yml
307+
npm run --workspace mongodb-compass build-info -- ${target_platform} ${target_arch} --format=yaml --flatten ${compass_distribution} --out expansions.raw.yml
308+
# the 'author' key conflicts with evergreen's own expansion
309+
grep -v '^author:' < packages/compass/expansions.raw.yml > packages/compass/expansions.yml
308310
- command: expansions.update
309311
params:
310312
# packaging and publishing is using all the *_filename variables
@@ -408,6 +410,8 @@ functions:
408410
SIGNING_SERVER_USERNAME: ${SIGNING_SERVER_USERNAME}
409411
SIGNING_SERVER_PORT: ${SIGNING_SERVER_PORT}
410412
GITHUB_PR_NUMBER: ${github_pr_number}
413+
PAPERTRAIL_KEY_ID: ${papertrail_key_id}
414+
PAPERTRAIL_SECRET_KEY: ${papertrail_secret_key}
411415
script: |
412416
set -e
413417
# Load environment variables
@@ -452,7 +456,7 @@ functions:
452456
set -e
453457
# Load environment variables
454458
eval $(.evergreen/print-compass-env.sh)
455-
.evergreen/create-static-analysis-report.sh
459+
.evergreen/create-static-analysis-report.sh
456460
- command: s3.put
457461
params:
458462
<<: *save-artifact-params-private

.github/workflows/start-beta.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ jobs:
4545
run: |
4646
node scripts/release.js beta \
4747
--merge-branch="${{ github.event.inputs.mergeBranch || 'main' }}" \
48-
--next-ga="${{ github.event.inputs.overrideNextGa }}"
48+
--next-ga="${{ github.event.inputs.overrideNextGa }}" \
49+
--submitter="${{ github.actor }}"

.github/workflows/start-ga.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ jobs:
4747
run: |
4848
node scripts/release.js ga \
4949
--release-ticket="${{ github.event.inputs.releaseTicket }}" \
50-
--merge-branch="${{ github.event.inputs.mergeBranch || 'beta-releases' }}"
50+
--merge-branch="${{ github.event.inputs.mergeBranch || 'beta-releases' }}" \
51+
--submitter="${{ github.actor }}"

.mailmap

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
Alena Khineika <[email protected]> Alena Khineika <>
2-
Alena Khineika <[email protected]> Alena Khineika <[email protected]>
3-
Alena Khineika <[email protected]> Alena Khineika <unknown>
4-
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
5-
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
6-
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
1+
Alena Khineika <[email protected]> Alena Khineika <[email protected]>
2+
Alena Khineika <[email protected]> Alena Khineika <>
3+
4+
Alena Khineika <[email protected]> Alena Khineika <unknown>
5+
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
6+
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
7+
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
8+
79
Anna Herlihy <[email protected]> aherlihy <[email protected]>
810
Anna Herlihy <[email protected]> anna herlihy <[email protected]>
11+
912
Brahm Gardner <[email protected]> brahmgardner <[email protected]>
1013
Fred Truman <[email protected]> Fred Truman <[email protected]>
1114
Greenkeeper[bot] <[email protected]> Greenkeeper <[email protected]>
15+
1216
Irina Shestak <[email protected]> Irina Shestak <[email protected]>
1317
Irina Shestak <[email protected]> Irina Shestak <[email protected]>
1418
Irina Shestak <[email protected]> lrlna <[email protected]>
@@ -17,32 +21,39 @@ Jonathan Balsano <[email protected]> Jonathan Balsano <jonathan.balsano
1721
Jonathan Balsano <[email protected]> Jonathan Balsano <[email protected]>
1822
Joy Sampoonachot <[email protected]> Joy Sampoonachot <[email protected]>
1923
Joy Sampoonachot <[email protected]> Joy Sampoonachot <[email protected]>
24+
2025
Kevin Meyer <[email protected]> kevinat10gen <[email protected]>
26+
Le Roux Bodenstein <[email protected]> <[email protected]>
2127
Lucas Hrabovsky <[email protected]> Lucas Hrabovsky <[email protected]>
2228
Marc Schäffner-Gurney <[email protected]> Marc Schaffner-Gurney <[email protected]>
2329
Massimiliano Marcon <[email protected]>Massimiliano Marcon <[email protected]>
2430
Matt Cotter <[email protected]> Matt Cotter <[email protected]>
2531
Matt Fairbrass <[email protected]> Matt Fairbrass <[email protected]>
2632
Matt Kangas <[email protected]> Matt Kangas <[email protected]>
27-
Maurizio Casimirri <[email protected]> Maurizio Casimirri <[email protected]>
28-
29-
Maurizio Casimirri <[email protected]> mcasimir <[email protected]>
33+
Maurizio Casimirri <[email protected]> Maurizio Casimirri <[email protected]>
34+
Maurizio Casimirri <[email protected]> Maurizio Casimirri <[email protected]>
35+
36+
Maurizio Casimirri <[email protected]> mcasimir <[email protected]>
37+
Maurizio Casimirri <[email protected]> <[email protected]>
3038
Michael Rose <[email protected]> rosem <[email protected]>
3139
Paul Thurlow <[email protected]> Paul Thurlow <[email protected]>
40+
3241
Preston Vasquez <[email protected]> Preston Vasquez <[email protected]>
33-
Rhys Howell <rhys@[email protected]> Anemy <rhys@[email protected]>
34-
Rhys Howell <rhys@[email protected]> Rhys <[email protected]>
35-
Rhys Howell <rhys@[email protected]> Rhys Howell <[email protected]>
42+
Rhys Howell <[email protected]> Rhys Howell <rhys@[email protected]>
43+
Rhys Howell <[email protected]> Anemy <rhys@[email protected]>
44+
45+
Rhys Howell <[email protected]> Rhys Howell <[email protected]>
3646
3747
Satya Sinha <[email protected]> satyasinha <[email protected]>
3848
39-
Sergey Petushkov <[email protected]> Sergey <[email protected]>
40-
Sergey Petushkov <[email protected]> Sergey Petushkov <[email protected]>
49+
Sergey Petushkov <[email protected]> Sergey <[email protected]>
50+
Sergey Petushkov <[email protected]> Sergey Petushkov <[email protected]>
51+
4152
snyk-bot[bot] <[email protected]> snyk-bot <[email protected]>
4253
Thomas Rueckstiess <[email protected]> Thomas Rückstieß <[email protected]>
4354
Thomas Rueckstiess <[email protected]> Thomas Rueckstiess <[email protected]>
4455
Thomas Rueckstiess <[email protected]> Thomas Rueckstiess <[email protected]>
4556
4657
4758
Yonatan Schreiber <[email protected]> yonatan <[email protected]>
48-
Yonatan Schreiber <[email protected]> yonatan s <[email protected]>
59+
Yonatan Schreiber <[email protected]> yonatan s <[email protected]>

packages/compass/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ report.json
1414
.compiled-sources/
1515
src/app/.compiled-less/
1616
expansions.yml
17+
expansions.raw.yml
1718
.nvmrc
1819
.vscode
1920
src/app/fonts/akzid*
2021
src/app/fonts/Euclid*
2122
src/app/fonts/MongoDB*
2223
.compile-cache-mappings.json
23-
THIRD-PARTY-NOTICES.md
24+
THIRD-PARTY-NOTICES.md

scripts/release.js

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ program
2323
.command('beta')
2424
.description('Starts a new beta')
2525
.option('--merge-branch <mergeBranch>', 'branch to merge', 'main')
26+
.option('--submitter <name>', 'github username of the releaser', '')
2627
.option(
2728
'--next-ga [nextGa]',
2829
'next ga version, default to the next GA version in Jira'
@@ -32,6 +33,10 @@ program
3233
if (!options.mergeBranch) {
3334
throw new Error('mergeBranch is required');
3435
}
36+
if (!options.submitter) {
37+
throw new Error('submitter is required');
38+
}
39+
const publisher = getReleasePublisher(options.submitter);
3540

3641
const nextGa = options.nextGa || (await getNextGaVersionInJira());
3742

@@ -62,13 +67,14 @@ program
6267
console.info(`Promoting ${currentCompassPackageVersion} to ${nextBeta}`);
6368

6469
await syncWithBranch(options.mergeBranch);
65-
await bumpAndPush(nextBeta, BETA_RELEASE_BRANCH);
70+
await bumpAndPush(nextBeta, BETA_RELEASE_BRANCH, publisher);
6671
});
6772

6873
program
6974
.command('ga')
7075
.description('Starts a new GA')
7176
.option('--release-ticket <releaseTicket>')
77+
.option('--submitter <name>', 'github username of the releaser', '')
7278
.option(
7379
'--merge-branch <mergeBranch>',
7480
'branch to merge',
@@ -83,6 +89,10 @@ program
8389
if (!options.mergeBranch) {
8490
throw new Error('mergeBranch is required');
8591
}
92+
if (!options.submitter) {
93+
throw new Error('submitter is required');
94+
}
95+
const publisher = getReleasePublisher(options.submitter);
8696

8797
const nextGa = await getReleaseVersionFromTicket(options.releaseTicket);
8898

@@ -104,7 +114,7 @@ program
104114
}
105115

106116
console.info(`Promoting ${currentCompassPackageVersion} to ${nextGa}`);
107-
await bumpAndPush(nextGa, GA_RELEASE_BRANCH);
117+
await bumpAndPush(nextGa, GA_RELEASE_BRANCH, publisher);
108118
});
109119

110120
program.parseAsync();
@@ -159,8 +169,37 @@ async function gitCheckout(branchName) {
159169
});
160170
}
161171

162-
async function bumpAndPush(nextVersion, releaseBranch) {
163-
await execFile('npm', ['version', nextVersion], { cwd: compassPackagePath });
172+
async function getReleasePublisher(submitter) {
173+
const publisherData = (
174+
await execFile(
175+
'git',
176+
['check-mailmap', `<${submitter}@users.noreply.github.com>`],
177+
{
178+
cwd: monorepoRoot,
179+
encoding: 'utf8',
180+
}
181+
)
182+
).stdout.trim();
183+
184+
if (!publisherData.match(/^[^<]+<[^@>]+@mongodb.com>/)) {
185+
throw new Error(
186+
`Could not translate username ${submitter} to recognized authorized email (${publisherData})`
187+
);
188+
}
189+
return publisherData;
190+
}
191+
192+
async function bumpAndPush(nextVersion, releaseBranch, publisher) {
193+
await execFile('npm', ['version', '--no-git-tag-version', nextVersion], {
194+
cwd: compassPackagePath,
195+
});
196+
await fs.writeFile(
197+
compassPackageJsonPath,
198+
JSON.stringify({
199+
...JSON.parse(await fs.readFile(compassPackageJsonPath, 'utf8')),
200+
releasePublisher: publisher,
201+
})
202+
);
164203
await execFile('git', ['add', compassPackageJsonPath, `package-lock.json`], {
165204
cwd: monorepoRoot,
166205
});
@@ -174,6 +213,26 @@ async function bumpAndPush(nextVersion, releaseBranch) {
174213
cwd: monorepoRoot,
175214
});
176215
await execFile('git', ['push', '--tags'], { cwd: monorepoRoot });
216+
217+
const currentBranch = (
218+
await execFile('git', ['branch', '--show-current'], {
219+
cwd: monorepoRoot,
220+
encoding: 'utf8',
221+
})
222+
).stdout.trim();
223+
await execFile(
224+
'gh',
225+
[
226+
'workflow',
227+
'run',
228+
'codeql.yml',
229+
'-R',
230+
'mongodb-js/compass',
231+
'-r',
232+
currentBranch,
233+
],
234+
{ cwd: monorepoRoot }
235+
);
177236
}
178237

179238
// NOTE: if there are more "unreleased" versions it will

0 commit comments

Comments
 (0)