Skip to content

Commit

Permalink
fix(ci): include releaser name in application artifacts COMPASS-7888 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax authored Jun 17, 2024
1 parent 4be36b4 commit e575004
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 24 deletions.
46 changes: 46 additions & 0 deletions .evergreen/compass_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,49 @@ npm run generate-first-party-deps-json

ls -la packages/compass/dist
ls -la .sbom

get_compass_package_json_field() {
node -p 'JSON.parse(fs.readFileSync("packages/compass/package.json"))['"'$1'"']'
}

papertrail() {
set +x
echo "X-PAPERTRAIL-KEY-ID: ${PAPERTRAIL_KEY_ID}" > .papertrail.headers
echo "X-PAPERTRAIL-SECRET-KEY: ${PAPERTRAIL_SECRET_KEY}" >> .papertrail.headers
set -x

version=$(get_compass_package_json_field version)
product="compass"
if echo "$version" | grep -q -- -dev. ; then
version+="${EVERGREEN_REVISION}_${EVERGREEN_REVISION_ORDER_ID}"
product+="-dev"
elif echo "$version" | grep -q -- -beta. ; then
product+="-beta"
fi
build="${EVERGREEN_TASK_ID}_${EVERGREEN_EXECUTION}"
platform="evergreen"
submitter=$(get_compass_package_json_field releasePublisher)
if [ $submitter = "null" ]; then
submitter="${EVERGREEN_AUTHOR}"
fi

for file in packages/compass/dist/* ; do
if [ -f "$file" ]; then
filename=$(basename "$file")
checksum=$(shasum -a 256 "$file" | cut -f1 -d' ')

curl -G -X POST -H @.papertrail.headers "https://papertrail.devprod-infra.prod.corp.mongodb.com/trace" \
--data-urlencode "version=${version}" \
--data-urlencode "product=${product}" \
--data-urlencode "sha256=${checksum}" \
--data-urlencode "filename=${filename}" \
--data-urlencode "build=${build}" \
--data-urlencode "platform=${platform}" \
--data-urlencode "submitter=${submitter}"
fi
done

rm -f .papertrail.headers
}

papertrail
8 changes: 6 additions & 2 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ functions:
# Load environment variables
eval $(.evergreen/print-compass-env.sh)
# Generates and expansion file with build target metadata in packages/compass/expansions.yml
npm run --workspace mongodb-compass build-info -- ${target_platform} ${target_arch} --format=yaml --flatten ${compass_distribution} --out expansions.yml
npm run --workspace mongodb-compass build-info -- ${target_platform} ${target_arch} --format=yaml --flatten ${compass_distribution} --out expansions.raw.yml
# the 'author' key conflicts with evergreen's own expansion
grep -v '^author:' < packages/compass/expansions.raw.yml > packages/compass/expansions.yml
- command: expansions.update
params:
# packaging and publishing is using all the *_filename variables
Expand Down Expand Up @@ -408,6 +410,8 @@ functions:
SIGNING_SERVER_USERNAME: ${SIGNING_SERVER_USERNAME}
SIGNING_SERVER_PORT: ${SIGNING_SERVER_PORT}
GITHUB_PR_NUMBER: ${github_pr_number}
PAPERTRAIL_KEY_ID: ${papertrail_key_id}
PAPERTRAIL_SECRET_KEY: ${papertrail_secret_key}
script: |
set -e
# Load environment variables
Expand Down Expand Up @@ -452,7 +456,7 @@ functions:
set -e
# Load environment variables
eval $(.evergreen/print-compass-env.sh)
.evergreen/create-static-analysis-report.sh
.evergreen/create-static-analysis-report.sh
- command: s3.put
params:
<<: *save-artifact-params-private
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/start-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ jobs:
run: |
node scripts/release.js beta \
--merge-branch="${{ github.event.inputs.mergeBranch || 'main' }}" \
--next-ga="${{ github.event.inputs.overrideNextGa }}"
--next-ga="${{ github.event.inputs.overrideNextGa }}" \
--submitter="${{ github.actor }}"
3 changes: 2 additions & 1 deletion .github/workflows/start-ga.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ jobs:
run: |
node scripts/release.js ga \
--release-ticket="${{ github.event.inputs.releaseTicket }}" \
--merge-branch="${{ github.event.inputs.mergeBranch || 'beta-releases' }}"
--merge-branch="${{ github.event.inputs.mergeBranch || 'beta-releases' }}" \
--submitter="${{ github.actor }}"
41 changes: 26 additions & 15 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
Alena Khineika <[email protected]> Alena Khineika <>
Alena Khineika <[email protected]> Alena Khineika <[email protected]>
Alena Khineika <[email protected]> Alena Khineika <unknown>
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
Alena Khineika <[email protected]> Alena Khineika <[email protected]>
Alena Khineika <[email protected]> Alena Khineika <>
Alena Khineika <[email protected]> <[email protected]>
Alena Khineika <[email protected]> Alena Khineika <unknown>
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
Anna Henningsen <[email protected]> Anna Henningsen <[email protected]>
Anna Henningsen <[email protected]> <[email protected]>
Anna Herlihy <[email protected]> aherlihy <[email protected]>
Anna Herlihy <[email protected]> anna herlihy <[email protected]>
Basit Chonka <[email protected]> <[email protected]>
Brahm Gardner <[email protected]> brahmgardner <[email protected]>
Fred Truman <[email protected]> Fred Truman <[email protected]>
Greenkeeper[bot] <[email protected]> Greenkeeper <[email protected]>
Himanshu Singh <[email protected]> <[email protected]>
Irina Shestak <[email protected]> Irina Shestak <[email protected]>
Irina Shestak <[email protected]> Irina Shestak <[email protected]>
Irina Shestak <[email protected]> lrlna <[email protected]>
Expand All @@ -17,32 +21,39 @@ Jonathan Balsano <[email protected]> Jonathan Balsano <jonathan.balsano
Jonathan Balsano <[email protected]> Jonathan Balsano <[email protected]>
Joy Sampoonachot <[email protected]> Joy Sampoonachot <[email protected]>
Joy Sampoonachot <[email protected]> Joy Sampoonachot <[email protected]>
Kevin Mas Ruiz <[email protected]> <[email protected]>
Kevin Meyer <[email protected]> kevinat10gen <[email protected]>
Le Roux Bodenstein <[email protected]> <[email protected]>
Lucas Hrabovsky <[email protected]> Lucas Hrabovsky <[email protected]>
Marc Schäffner-Gurney <[email protected]> Marc Schaffner-Gurney <[email protected]>
Massimiliano Marcon <[email protected]>Massimiliano Marcon <[email protected]>
Matt Cotter <[email protected]> Matt Cotter <[email protected]>
Matt Fairbrass <[email protected]> Matt Fairbrass <[email protected]>
Matt Kangas <[email protected]> Matt Kangas <[email protected]>
Maurizio Casimirri <[email protected]> Maurizio Casimirri <[email protected]>
Maurizio Casimirri <[email protected]> [email protected] <[email protected]>
Maurizio Casimirri <[email protected]> mcasimir <[email protected]>
Maurizio Casimirri <[email protected]> Maurizio Casimirri <[email protected]>
Maurizio Casimirri <[email protected]> Maurizio Casimirri <[email protected]>
Maurizio Casimirri <[email protected]> [email protected] <[email protected]>
Maurizio Casimirri <[email protected]> mcasimir <[email protected]>
Maurizio Casimirri <[email protected]> <[email protected]>
Michael Rose <[email protected]> rosem <[email protected]>
Paul Thurlow <[email protected]> Paul Thurlow <[email protected]>
Paula Stachova <[email protected]> <[email protected]>
Preston Vasquez <[email protected]> Preston Vasquez <[email protected]>
Rhys Howell <rhys@[email protected]> Anemy <rhys@[email protected]>
Rhys Howell <rhys@[email protected]> Rhys <[email protected]>
Rhys Howell <rhys@[email protected]> Rhys Howell <[email protected]>
Rhys Howell <[email protected]> Rhys Howell <rhys@[email protected]>
Rhys Howell <[email protected]> Anemy <rhys@[email protected]>
Rhys Howell <[email protected]> <[email protected]>
Rhys Howell <[email protected]> Rhys Howell <[email protected]>
Satya Sinha <[email protected]> Satya <[email protected]>
Satya Sinha <[email protected]> satyasinha <[email protected]>
Sean Oh <[email protected]> Sean Oh <[email protected]>
Sergey Petushkov <[email protected]> Sergey <[email protected]>
Sergey Petushkov <[email protected]> Sergey Petushkov <[email protected]>
Sergey Petushkov <[email protected]> Sergey <[email protected]>
Sergey Petushkov <[email protected]> Sergey Petushkov <[email protected]>
Sergey Petushkov <[email protected]> <[email protected]>
snyk-bot[bot] <[email protected]> snyk-bot <[email protected]>
Thomas Rueckstiess <[email protected]> Thomas Rückstieß <[email protected]>
Thomas Rueckstiess <[email protected]> Thomas Rueckstiess <[email protected]>
Thomas Rueckstiess <[email protected]> Thomas Rueckstiess <[email protected]>
Waley <[email protected]> Waley <[email protected]>
Waley <[email protected]> Waley Chen <[email protected]>
Yonatan Schreiber <[email protected]> yonatan <[email protected]>
Yonatan Schreiber <[email protected]> yonatan s <[email protected]>
Yonatan Schreiber <[email protected]> yonatan s <[email protected]>
3 changes: 2 additions & 1 deletion packages/compass/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ report.json
.compiled-sources/
src/app/.compiled-less/
expansions.yml
expansions.raw.yml
.nvmrc
.vscode
src/app/fonts/akzid*
src/app/fonts/Euclid*
src/app/fonts/MongoDB*
.compile-cache-mappings.json
THIRD-PARTY-NOTICES.md
THIRD-PARTY-NOTICES.md
67 changes: 63 additions & 4 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ program
.command('beta')
.description('Starts a new beta')
.option('--merge-branch <mergeBranch>', 'branch to merge', 'main')
.option('--submitter <name>', 'github username of the releaser', '')
.option(
'--next-ga [nextGa]',
'next ga version, default to the next GA version in Jira'
Expand All @@ -32,6 +33,10 @@ program
if (!options.mergeBranch) {
throw new Error('mergeBranch is required');
}
if (!options.submitter) {
throw new Error('submitter is required');
}
const publisher = getReleasePublisher(options.submitter);

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

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

await syncWithBranch(options.mergeBranch);
await bumpAndPush(nextBeta, BETA_RELEASE_BRANCH);
await bumpAndPush(nextBeta, BETA_RELEASE_BRANCH, publisher);
});

program
.command('ga')
.description('Starts a new GA')
.option('--release-ticket <releaseTicket>')
.option('--submitter <name>', 'github username of the releaser', '')
.option(
'--merge-branch <mergeBranch>',
'branch to merge',
Expand All @@ -83,6 +89,10 @@ program
if (!options.mergeBranch) {
throw new Error('mergeBranch is required');
}
if (!options.submitter) {
throw new Error('submitter is required');
}
const publisher = getReleasePublisher(options.submitter);

const nextGa = await getReleaseVersionFromTicket(options.releaseTicket);

Expand All @@ -104,7 +114,7 @@ program
}

console.info(`Promoting ${currentCompassPackageVersion} to ${nextGa}`);
await bumpAndPush(nextGa, GA_RELEASE_BRANCH);
await bumpAndPush(nextGa, GA_RELEASE_BRANCH, publisher);
});

program.parseAsync();
Expand Down Expand Up @@ -159,8 +169,37 @@ async function gitCheckout(branchName) {
});
}

async function bumpAndPush(nextVersion, releaseBranch) {
await execFile('npm', ['version', nextVersion], { cwd: compassPackagePath });
async function getReleasePublisher(submitter) {
const publisherData = (
await execFile(
'git',
['check-mailmap', `<${submitter}@users.noreply.github.com>`],
{
cwd: monorepoRoot,
encoding: 'utf8',
}
)
).stdout.trim();

if (!publisherData.match(/^[^<]+<[^@>][email protected]>/)) {
throw new Error(
`Could not translate username ${submitter} to recognized authorized email (${publisherData})`
);
}
return publisherData;
}

async function bumpAndPush(nextVersion, releaseBranch, publisher) {
await execFile('npm', ['version', '--no-git-tag-version', nextVersion], {
cwd: compassPackagePath,
});
await fs.writeFile(
compassPackageJsonPath,
JSON.stringify({
...JSON.parse(await fs.readFile(compassPackageJsonPath, 'utf8')),
releasePublisher: publisher,
})
);
await execFile('git', ['add', compassPackageJsonPath, `package-lock.json`], {
cwd: monorepoRoot,
});
Expand All @@ -174,6 +213,26 @@ async function bumpAndPush(nextVersion, releaseBranch) {
cwd: monorepoRoot,
});
await execFile('git', ['push', '--tags'], { cwd: monorepoRoot });

const currentBranch = (
await execFile('git', ['branch', '--show-current'], {
cwd: monorepoRoot,
encoding: 'utf8',
})
).stdout.trim();
await execFile(
'gh',
[
'workflow',
'run',
'codeql.yml',
'-R',
'mongodb-js/compass',
'-r',
currentBranch,
],
{ cwd: monorepoRoot }
);
}

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

0 comments on commit e575004

Please sign in to comment.