Skip to content

Commit 45e9b12

Browse files
authored
add notarizing (#275)
1 parent 4840bec commit 45e9b12

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

.evergreen.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
variables:
2+
3+
functions:
4+
5+
"clone":
6+
- command: subprocess.exec
7+
type: setup
8+
params:
9+
command: "mkdir -p src/github.com/mongodb"
10+
- command: git.get_project
11+
type: setup
12+
params:
13+
directory: src/github.com/mongodb/mongodb-enterprise-kubernetes
14+
15+
"install goreleaser":
16+
- command: shell.exec
17+
type: setup
18+
include_expansions_in_env:
19+
- goreleaser_pro_tar_gz
20+
params:
21+
script: |
22+
set -Eeu pipefail
23+
24+
curl -fL "${goreleaser_pro_tar_gz}" --output goreleaser_Linux_x86_64.tar.gz
25+
tar -xf goreleaser_Linux_x86_64.tar.gz
26+
chmod 755 ./goreleaser
27+
28+
"install macos notarization service":
29+
- command: shell.exec
30+
type: setup
31+
params:
32+
include_expansions_in_env:
33+
- notary_service_url
34+
script: |
35+
set -Eeu pipefail
36+
37+
curl "${notary_service_url}" --output macos-notary.zip
38+
unzip -u macos-notary.zip
39+
chmod 755 ./linux_amd64/macnotary
40+
"release":
41+
- command: shell.exec
42+
type: setup
43+
params:
44+
working_dir: src/github.com/mongodb/mongodb-enterprise-kubernetes/tools/multicluster
45+
add_to_path:
46+
- src/github.com/mongodb/tools
47+
- src/github.com/mongodb/tools/linux_amd64
48+
include_expansions_in_env:
49+
- GITHUB_TOKEN
50+
- macos_notary_keyid
51+
- macos_notary_secret
52+
- workdir
53+
env:
54+
MACOS_NOTARY_KEY: ${macos_notary_keyid}
55+
MACOS_NOTARY_SECRET: ${macos_notary_secret}
56+
script: |
57+
set -Eeu pipefail
58+
59+
${workdir}/goreleaser release
60+
61+
tasks:
62+
- name: package_goreleaser
63+
tags: ["packaging"]
64+
commands:
65+
- func: "clone"
66+
- func: "install goreleaser"
67+
- func: "install macos notarization service"
68+
- func: "release"
69+
70+
buildvariants:
71+
72+
# This variant is kept manual for now in order avoid any interfering with the existing release process.
73+
# In the future, it will be called in one of two ways:
74+
# By PCT when a new operator version is released.
75+
# When a new tag is out similarly to github actions.
76+
- name: release_mcli
77+
display_name: Release Go multi-cluster binary
78+
run_on:
79+
- ubuntu2204-small
80+
tasks:
81+
- name: package_goreleaser

tools/multicluster/.goreleaser.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ builds:
1414
- amd64
1515
- arm64
1616

17+
hooks:
18+
# This will notarize Apple binaries and replace goreleaser bins with the notarized ones
19+
post:
20+
- cmd: ./kubectl_mac_notarize.sh
21+
output: true
1722

1823
archives:
1924
- format: tar.gz
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 MongoDB Inc
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -Eeou pipefail
18+
19+
# Notarize generated binaries with Apple and replace the original binary with the notarized one
20+
# This depends on binaries being generated in a goreleaser manner and gon being set up.
21+
# goreleaser should already take care of calling this script as a hook.
22+
23+
if [[ -f "./dist/kubectl-mongodb_darwin_arm64/kubectl-mongodb" && -f "./dist/kubectl-mongodb_darwin_amd64_v1/kubectl-mongodb" && ! -f "./dist/kubectl-mongodb_macos_signed.zip" ]]; then
24+
echo "notarizing macOs binaries"
25+
zip -r ./dist/kubectl-mongodb_amd64_arm64_bin.zip ./dist/kubectl-mongodb_darwin_amd64_v1/kubectl-mongodb ./dist/kubectl-mongodb_darwin_arm64/kubectl-mongodb # The Notarization Service takes an archive as input
26+
"${workdir-}"/macnotary \
27+
-f ./dist/kubectl-mongodb_amd64_arm64_bin.zip \
28+
-m notarizeAndSign -u https://dev.macos-notary.build.10gen.cc/api \
29+
-b com.mongodb.mongodb-kubectl-mongodb \
30+
-o ./dist/kubectl-mongodb_macos_signed.zip
31+
32+
echo "replacing original files"
33+
unzip -oj ./dist/kubectl-mongodb_macos_signed.zip dist/macos_darwin_amd64_v1/kubectl-mongodb -d ./dist/macos_darwin_amd64_v1/
34+
unzip -oj ./dist/kubectl-mongodb_macos_signed.zip dist/macos_darwin_arm64/kubectl-mongodb -d ./dist/macos_darwin_arm64/
35+
fi

0 commit comments

Comments
 (0)