Skip to content

Commit 52a5795

Browse files
authored
chore(garasign): sign linux artifacts (#5334)
* sign deb * sign linux tar * almost blew windows signing * package update
1 parent 1db0743 commit 52a5795

File tree

4 files changed

+127
-42
lines changed

4 files changed

+127
-42
lines changed

.evergreen/functions.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ variables:
8080
MONGODB_RUNNER_LOG_DIR: ${workdir}/src/.testserver/
8181
E2E_TESTS_ATLAS_CS_WITHOUT_SEARCH: ${e2e_tests_atlas_cs_without_search}
8282
E2E_TESTS_ATLAS_CS_WITH_SEARCH: ${e2e_tests_atlas_cs_with_search}
83+
GARASIGN_USERNAME: ${garasign_username}
84+
GARASIGN_PASSWORD: ${garasign_password}
85+
ARTIFACTORY_USERNAME: ${artifactory_username}
86+
ARTIFACTORY_PASSWORD: ${artifactory_password}
8387

8488
# This is here with the variables because anchors aren't supported across includes
8589
post:
@@ -551,13 +555,27 @@ functions:
551555
remote_file: ${project}/${revision}_${revision_order_id}/${linux_deb_filename}
552556
content_type: application/vnd.debian.binary-package
553557
optional: true
558+
- command: s3.put
559+
params:
560+
<<: *save-artifact-params-public
561+
local_file: src/packages/compass/dist/${linux_deb_sign_filename}
562+
remote_file: ${project}/${revision}_${revision_order_id}/${linux_deb_sign_filename}
563+
content_type: application/pgp-signature
564+
optional: true
554565
- command: s3.put
555566
params:
556567
<<: *save-artifact-params-public
557568
local_file: src/packages/compass/dist/${linux_tar_filename}
558569
remote_file: ${project}/${revision}_${revision_order_id}/${linux_tar_filename}
559570
content_type: application/x-gzip
560571
optional: true
572+
- command: s3.put
573+
params:
574+
<<: *save-artifact-params-public
575+
local_file: src/packages/compass/dist/${linux_tar_sign_filename}
576+
remote_file: ${project}/${revision}_${revision_order_id}/${linux_tar_sign_filename}
577+
content_type: application/pgp-signature
578+
optional: true
561579

562580
get-all-artifacts:
563581
- command: shell.exec

package-lock.json

Lines changed: 76 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/hadron-build/lib/target.js

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@ const mongodbNotaryServiceClient = require('@mongodb-js/mongodb-notary-service-c
1818
const which = require('which');
1919
const plist = require('plist');
2020
const { signtool } = require('./signtool');
21+
const { sign: garasign } = require('@mongodb-js/signing-utils');
2122
const tarGz = require('./tar-gz');
2223

23-
async function signLinuxPackage(src) {
24-
debug('Signing ... %s', src);
24+
async function signLocallyWithGpg(src) {
25+
debug('Signing locally with gpg ... %s', src);
26+
await garasign(src, {
27+
client: 'local',
28+
signingMethod: 'gpg',
29+
});
30+
debug('Successfully signed %s', src);
31+
}
32+
33+
async function signRpmPackage(src) {
34+
debug('Signing rpm .. %s', src);
2535
await mongodbNotaryServiceClient(src);
2636
debug('Successfully signed %s', src);
2737
}
@@ -646,6 +656,9 @@ class Target {
646656
const debianArch = this.arch === 'x64' ? 'amd64' : 'i386';
647657
const debianSection = _.get(platformSettings, 'deb_section');
648658
this.linux_deb_filename = `${this.slug}_${debianVersion}_${debianArch}.deb`;
659+
this.linux_deb_sign_filename = `${this.linux_deb_filename}.sig`;
660+
this.linux_tar_filename = `${this.slug}-${this.version}-${this.platform}-${this.arch}.tar.gz`;
661+
this.linux_tar_sign_filename = `${this.linux_tar_filename}.sig`;
649662

650663
const rhelVersion = [
651664
this.semver.major,
@@ -656,7 +669,6 @@ class Target {
656669
const rhelArch = this.arch === 'x64' ? 'x86_64' : 'i386';
657670
const rhelCategories = _.get(platformSettings, 'rpm_categories');
658671
this.linux_rpm_filename = `${this.slug}-${this.version}.${rhelArch}.rpm`;
659-
this.linux_tar_filename = `${this.slug}-${this.version}-${this.platform}-${this.arch}.tar.gz`;
660672
this.rhel_tar_filename = `${this.slug}-${this.version}-rhel-${this.arch}.tar.gz`;
661673

662674
this.assets = [
@@ -665,6 +677,10 @@ class Target {
665677
path: this.dest(this.linux_deb_filename),
666678
downloadCenter: true
667679
},
680+
{
681+
name: this.linux_deb_sign_filename,
682+
path: this.dest(this.linux_deb_sign_filename),
683+
},
668684
{
669685
name: this.linux_rpm_filename,
670686
path: this.dest(this.linux_rpm_filename),
@@ -674,6 +690,10 @@ class Target {
674690
name: this.linux_tar_filename,
675691
path: this.dest(this.linux_tar_filename)
676692
},
693+
{
694+
name: this.linux_tar_sign_filename,
695+
path: this.dest(this.linux_tar_sign_filename)
696+
},
677697
{
678698
name: this.rhel_tar_filename,
679699
path: this.dest(this.rhel_tar_filename)
@@ -731,7 +751,7 @@ class Target {
731751
const createRpm = require('electron-installer-redhat');
732752
debug('creating rpm...', this.installerOptions.rpm);
733753
return createRpm(this.installerOptions.rpm).then(() => {
734-
return signLinuxPackage(this.dest(this.linux_rpm_filename));
754+
return signRpmPackage(this.dest(this.linux_rpm_filename));
735755
});
736756
});
737757
};
@@ -741,12 +761,7 @@ class Target {
741761
const createDeb = require('electron-installer-debian');
742762
debug('creating deb...', this.installerOptions.deb);
743763
return createDeb(this.installerOptions.deb).then(() => {
744-
// We do not sign debs because it doesn't work, see
745-
// this thread for context:
746-
// https://mongodb.slack.com/archives/G2L10JAV7/p1623169331107600
747-
//
748-
// return sign(this.dest(this.linux_deb_filename));
749-
return this.dest(this.linux_deb_filename);
764+
return signLocallyWithGpg(this.dest(this.linux_deb_filename));
750765
});
751766
});
752767
};
@@ -758,7 +773,12 @@ class Target {
758773
this.dest(this.app_archive_name)
759774
);
760775

761-
return tarGz(this.appPath, this.dest(this.app_archive_name));
776+
return tarGz(this.appPath, this.dest(this.app_archive_name)).then(() => {
777+
if (process.env.EVERGREEN_BUILD_VARIANT === 'rhel') {
778+
return;
779+
}
780+
return signLocallyWithGpg(this.dest(this.app_archive_name));
781+
});
762782
};
763783

764784
this.createInstaller = () => {

packages/hadron-build/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
"url": "https://github.com/mongodb-js/compass.git"
2020
},
2121
"dependencies": {
22+
"@electron/rebuild": "^3.4.1",
2223
"@mongodb-js/devtools-github-repo": "^1.4.1",
2324
"@mongodb-js/dl-center": "^1.0.1",
2425
"@mongodb-js/electron-wix-msi": "^3.0.0",
2526
"@mongodb-js/mongodb-notary-service-client": "^2.0.4",
27+
"@mongodb-js/signing-utils": "^0.2.3",
2628
"@npmcli/arborist": "^6.2.0",
2729
"@octokit/rest": "^18.6.2",
2830
"asar": "^3.0.3",
@@ -36,7 +38,6 @@
3638
"electron": "^28.1.0",
3739
"electron-packager": "^15.5.1",
3840
"electron-packager-plugin-non-proprietary-codecs-ffmpeg": "^1.0.2",
39-
"@electron/rebuild": "^3.4.1",
4041
"flatnest": "^1.0.0",
4142
"fs-extra": "^8.1.0",
4243
"getos": "^3.1.4",

0 commit comments

Comments
 (0)