Skip to content

Commit 8ece9ae

Browse files
authored
Tidy sign_artifacts.sh (#749)
This applies 3 changes: - Teach `macos_notarize_and_sign()` to fetch architecture-specific `macnotary` binaries. (Thus, if Rosetta breaks again, we won’t lose our ability to push builds.) - Fix shellcheck warnings. - Switch to long-form CLI args for `podman`.
1 parent 0f0365f commit 8ece9ae

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

scripts/sign_artifacts.sh

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/bin/bash
2+
13
set -o errexit
24

35
pgp_sign() {
@@ -7,8 +9,8 @@ pgp_sign() {
79
podman run \
810
--env-file=signing-envfile \
911
--rm \
10-
-v $PWD:$PWD \
11-
-w $PWD \
12+
--volume "$PWD:$PWD" \
13+
--workdir "$PWD" \
1214
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg \
1315
/bin/bash -c "gpgloader && gpg --yes -v --armor -o ${signature_name} --detach-sign ${file_name}"
1416
}
@@ -19,16 +21,16 @@ authenticode_sign() {
1921
podman run \
2022
--env-file=signing-envfile \
2123
--rm \
22-
-v $PWD:$PWD \
23-
-w $PWD \
24+
--volume "$PWD:$PWD" \
25+
--workdir "$PWD" \
2426
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-jsign \
2527
/bin/bash -c "jsign -a ${AUTHENTICODE_KEY_NAME} --replace --tsaurl http://timestamp.digicert.com -d SHA-256 ${file_name}"
2628
}
2729

2830
setup_garasign_authentication() {
2931
set +x
3032

31-
echo "${ARTIFACTORY_PASSWORD}" | podman login --password-stdin --username ${ARTIFACTORY_USERNAME} artifactory.corp.mongodb.com
33+
echo "${ARTIFACTORY_PASSWORD}" | podman login --password-stdin --username "${ARTIFACTORY_USERNAME}" artifactory.corp.mongodb.com
3234

3335
echo "GRS_CONFIG_USER1_USERNAME=${GARASIGN_USERNAME}" >> "signing-envfile"
3436
echo "GRS_CONFIG_USER1_PASSWORD=${GARASIGN_PASSWORD}" >> "signing-envfile"
@@ -50,15 +52,32 @@ macos_notarize_and_sign() {
5052
# turn the untarred package into a zip
5153
zip -r unsigned.zip "$pkgname"
5254

53-
curl -LO https://macos-notary-1628249594.s3.amazonaws.com/releases/client/v3.3.3/darwin_amd64.zip
54-
unzip darwin_amd64.zip
55-
chmod 0755 ./darwin_amd64/macnotary
56-
./darwin_amd64/macnotary -v
55+
uname_arch=$(uname -m)
56+
57+
case "$uname_arch" in
58+
arm64)
59+
myarch=arm64
60+
;;
61+
x86_64)
62+
myarch=amd64
63+
;;
64+
*)
65+
echo "Unknown architecture: $uname_arch"
66+
exit 1
67+
esac
68+
69+
macnotary_dir=darwin_${myarch}
70+
zip_filename=${macnotary_dir}.zip
71+
72+
curl -LO "https://macos-notary-1628249594.s3.amazonaws.com/releases/client/v3.3.3/$zip_filename"
73+
unzip "$zip_filename"
74+
chmod 0755 "./$macnotary_dir/macnotary"
75+
"./$macnotary_dir/macnotary" -v
5776

5877
# The key id and secret were set as MACOS_NOTARY_KEY and MACOS_NOTARY_SECRET
5978
# env vars from the expansions. The macnotary client will look for these env
6079
# vars so we don't need to pass the credentials as CLI options.
61-
./darwin_amd64/macnotary \
80+
"./$macnotary_dir/macnotary" \
6281
--task-comment "signing the mongo-database-tools release" \
6382
--task-id "$TASK_ID" \
6483
--file "$PWD/unsigned.zip" \
@@ -83,7 +102,9 @@ case $MONGO_OS in
83102

84103
*)
85104
setup_garasign_authentication
86-
for file in $(ls mongodb-database-tools*.{tgz,deb,rpm}); do
105+
for file in mongodb-database-tools*.{tgz,deb,rpm}; do
106+
[ -e "$file" ] || continue
107+
87108
pgp_sign "$file" "$file.sig"
88109
done
89110
;;

0 commit comments

Comments
 (0)