Skip to content

Commit 0abff75

Browse files
authored
CLOUDP-177522 Move cli signing to garasign (#2558)
1 parent af1c7c5 commit 0abff75

13 files changed

+141
-291
lines changed

build/ci/evergreen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ functions:
204204
working_dir: src/github.com/mongodb/mongodb-atlas-cli/bin
205205
shell: bash
206206
script: |
207-
set -Eeou pipefail
207+
set -Eeou pipefail
208208
if [ -n "$(which yum 2>/dev/null)" ]; then
209209
sudo yum install -y podman
210210
elif [ -n "$(which apt-get 2>/dev/null)" ]; then

build/ci/release.yml

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ functions:
7373
NOTARY_SIGNING_COMMENT: "Evergreen Automatic Signing (${tool_name})"
7474
NOTARY_AUTH_TOKEN: ${signing_auth_token_50}
7575
NOTARY_URL: ${notary_service_notary_url}
76+
ARTIFACTORY_USERNAME: ${artifactory_username}
77+
ARTIFACTORY_PASSWORD: ${artifactory_password}
78+
GRS_USERNAME: ${garasign_username}
79+
GRS_PASSWORD: ${garasign_password}
7680
include_expansions_in_env:
7781
- go_base_path
7882
- workdir
@@ -112,12 +116,12 @@ functions:
112116
env:
113117
<<: *go_env
114118
TOOL_NAME: ${TOOL_NAME}
115-
NOTARY_SIGNING_KEY_MONGOCLI: ${notary_service_signing_key_mongocli}
116-
NOTARY_SIGNING_KEY_ATLASCLI: ${notary_service_signing_key_atlascli}
117-
NOTARY_SIGNING_COMMENT: "Evergreen Automatic Signing (${TOOL_NAME})"
118-
NOTARY_AUTH_TOKEN: ${signing_auth_token_50}
119-
NOTARY_URL: ${notary_service_notary_url}
120119
SECRET_API_KEY: ${chocolatey_api_key}
120+
ARTIFACTORY_USERNAME: ${artifactory_username}
121+
ARTIFACTORY_PASSWORD: ${artifactory_password}
122+
GRS_USERNAME: ${garasign_username}
123+
GRS_PASSWORD: ${garasign_password}
124+
unstable: ${unstable}
121125
command: bash.exe -c build/package/generate-msi.sh
122126
"update choco":
123127
- command: subprocess.exec
@@ -282,6 +286,7 @@ tasks:
282286
- func: "generate msi"
283287
vars:
284288
TOOL_NAME: ${tool_name}
289+
unstable: -unstable
285290
- func: "uninstall go-msi"
286291
- command: s3.put
287292
params:
@@ -323,12 +328,27 @@ tasks:
323328
commands:
324329
- func: "generate notices"
325330
- func: "install goreleaser"
331+
- func: "install podman"
326332
- func: "install macos notarization service"
333+
- command: subprocess.exec
334+
type: test
335+
params:
336+
working_dir: src/github.com/mongodb/mongodb-atlas-cli
337+
include_expansions_in_env:
338+
- project
339+
- revision
340+
- created_at
341+
env:
342+
TOOL_NAME: ${tool_name}
343+
BUCKET: mongodb-mongocli-build
344+
unstable: -unstable
345+
binary: build/package/download-msi.sh
327346
- func: "package"
328347
vars:
329348
unstable: -unstable
330349
tool_name: ${tool_name}
331350
goreleaser_config: ${goreleaser_file}
351+
changelog_file: ${changelog_file}
332352
- func: "rename pkg"
333353
vars:
334354
unstable: -unstable
@@ -424,13 +444,19 @@ tasks:
424444
commands:
425445
- func: "generate notices"
426446
- func: "install goreleaser"
447+
- func: "install podman"
427448
- func: "install macos notarization service"
428449
- command: subprocess.exec
429450
type: test
430451
params:
431452
working_dir: src/github.com/mongodb/mongodb-atlas-cli
453+
include_expansions_in_env:
454+
- project
455+
- revision
456+
- created_at
432457
env:
433458
TOOL_NAME: mongocli
459+
BUCKET: mongodb-mongocli-build
434460
binary: build/package/download-msi.sh
435461
- func: "package"
436462
vars:
@@ -481,6 +507,7 @@ tasks:
481507
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.rpm
482508
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.tgz
483509
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.json
510+
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.msi
484511
remote_file: mongocli/
485512
bucket: downloads.mongodb.org
486513
permissions: public-read
@@ -500,13 +527,19 @@ tasks:
500527
commands:
501528
- func: "generate notices"
502529
- func: "install goreleaser"
530+
- func: "install podman"
503531
- func: "install macos notarization service"
504532
- command: subprocess.exec
505533
type: test
506534
params:
507535
working_dir: src/github.com/mongodb/mongodb-atlas-cli
536+
include_expansions_in_env:
537+
- project
538+
- revision
539+
- created_at
508540
env:
509541
TOOL_NAME: atlascli
542+
BUCKET: mongodb-mongocli-build
510543
binary: build/package/download-msi.sh
511544
- func: "package"
512545
vars:
@@ -558,6 +591,7 @@ tasks:
558591
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.rpm
559592
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.tgz
560593
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.json
594+
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.msi
561595
remote_file: mongocli/
562596
bucket: downloads.mongodb.org
563597
permissions: public-read
@@ -612,17 +646,6 @@ tasks:
612646
bucket: mongodb-mongocli-build
613647
permissions: public-read
614648
content_type: ${content_type|text/plain}
615-
- command: s3.put
616-
params:
617-
aws_key: ${download_center_aws_key}
618-
aws_secret: ${download_center_aws_secret}
619-
local_files_include_filter:
620-
- src/github.com/mongodb/mongodb-atlas-cli/dist/*.msi
621-
remote_file: mongocli/
622-
bucket: downloads.mongodb.org
623-
permissions: public-read
624-
content_type: ${content_type|application/octet-stream}
625-
display_name: downloads-center-
626649
- name: pkg_test_repo_atlascli
627650
patchable: false
628651
git_tag_only: true
@@ -684,10 +707,14 @@ buildvariants:
684707
<<: *go_linux_version
685708
server_version: "4.4.0-rc3"
686709
goreleaser_file: "build/package/.mongocli.goreleaser.yml"
710+
changelog_file: CHANGELOG_MONGOCLI.md
687711
package_name: "mongocli"
688712
tool_name: "mongocli"
689713
tasks:
690714
- name: package_goreleaser
715+
depends_on:
716+
- name: package_msi
717+
variant: "go_mongocli_msi_snapshot"
691718
- name: goreleaser_atlascli_snapshot
692719
display_name: "Packaging AtlasCLI (goreleaser)"
693720
run_on:
@@ -696,11 +723,15 @@ buildvariants:
696723
<<: *go_linux_version
697724
server_version: "4.4.0-rc3"
698725
goreleaser_file: "build/package/.atlascli.goreleaser.yml"
726+
changelog_file: CHANGELOG_ATLASCLI.md
699727
package_name: "mongodb-atlas-cli"
700728
meta_package_name: "mongodb-atlas"
701729
tool_name: "atlascli"
702730
tasks:
703731
- name: package_goreleaser
732+
depends_on:
733+
- name: package_msi
734+
variant: "go_atlascli_msi_snapshot"
704735
- name: publish_mongocli_snapshot
705736
display_name: "Publish MongoCLI Snapshot"
706737
run_on:

build/package/.atlascli.goreleaser.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ builds:
3232
goos: [windows]
3333
goarch: [amd64]
3434
hooks:
35-
post: ./build/package/atlascli_windows_notarize.sh
35+
post:
36+
- cmd: ./build/package/windows_notarize.sh
37+
env:
38+
- TOOL_NAME=atlascli
39+
- VERSION={{ .Version }}
40+
output: true
3641
archives:
3742
- id: linux
3843
name_template: "mongodb-atlas-cli_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
@@ -114,4 +119,4 @@ release:
114119
prerelease: auto
115120
name_template: "MongoDB Atlas CLI {{.Version}}"
116121
extra_files:
117-
- glob: ./bin/*.msi
122+
- glob: ./dist/*.msi

build/package/.mongocli.goreleaser.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ builds:
2525
hooks:
2626
# This will notarize Apple binaries and replace goreleaser bins with the notarized ones
2727
post:
28-
- cmd: ./build/package/mongocli_mac_notarize.sh
29-
output: true
28+
- cmd: ./build/package/mongocli_mac_notarize.sh
29+
output: true
3030
- <<: *build_defaults
3131
id: windows
3232
goos: [windows]
3333
goarch: [amd64]
3434
hooks:
35-
post: ./build/package/mongocli_windows_notarize.sh
35+
post:
36+
- cmd: ./build/package/windows_notarize.sh
37+
env:
38+
- TOOL_NAME=mongocli
39+
- VERSION={{ .Version }}
40+
output: true
3641
archives:
3742
- id: linux
3843
builds: [linux]
@@ -85,4 +90,4 @@ release:
8590
prerelease: auto
8691
name_template: "MongoDB CLI {{.Version}}"
8792
extra_files:
88-
- glob: ./bin/*.msi
93+
- glob: ./dist/*.msi

build/package/atlascli_windows_notarize.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

build/package/download-msi.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@
1515

1616
set -Eeou pipefail
1717

18-
VERSION="$(git tag --list "${TOOL_NAME:?}/v*" --sort=taggerdate | tail -1 | cut -d "v" -f 2)"
18+
export project
19+
export revision
20+
export created_at
1921

20-
PACKAGE_NAME=mongocli_"${VERSION}"_windows_x86_64.msi
22+
VERSION_GIT="$(git tag --list "${TOOL_NAME:?}/v*" --sort=taggerdate | tail -1 | cut -d "v" -f 2)"
23+
VERSION_NAME="$VERSION_GIT"
24+
if [[ "${unstable-}" == "-unstable" ]]; then
25+
VERSION_NAME="$VERSION_GIT-next"
26+
fi
27+
28+
PACKAGE_NAME="mongocli_${VERSION_NAME}_windows_x86_64.msi"
2129
if [[ "${TOOL_NAME:?}" == atlascli ]]; then
22-
PACKAGE_NAME=mongodb-atlas-cli_${VERSION}_windows_x86_64.msi
30+
PACKAGE_NAME="mongodb-atlas-cli_${VERSION_NAME}_windows_x86_64.msi"
2331
fi
2432

2533
pushd bin
2634

27-
curl https://fastdl.mongodb.org/mongocli/"${PACKAGE_NAME}" --output "${PACKAGE_NAME}"
35+
echo "downloading https://${BUCKET}.s3.amazonaws.com/${project}/dist/${revision}_${created_at}/${PACKAGE_NAME} into $PWD"
36+
curl "https://${BUCKET}.s3.amazonaws.com/${project}/dist/${revision}_${created_at}/${PACKAGE_NAME}" --output "${PACKAGE_NAME}"

build/package/generate-msi.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ GOCACHE="$(cygpath --mixed "${workdir:?}\.gocache")"
1919
CGO_ENABLED=0
2020
export GOCACHE
2121
export CGO_ENABLED
22-
export NOTARY_SIGNING_KEY
2322

2423
go-msi check-env
2524

26-
VERSION_GIT="$(git describe --match "${TOOL_NAME:?}/v*" | cut -d "v" -f 2)"
25+
VERSION_GIT="$(git tag --list "${TOOL_NAME:?}/v*" --sort=taggerdate | tail -1 | cut -d "v" -f 2)"
26+
VERSION_NAME="$VERSION_GIT"
27+
if [[ "${unstable-}" == "-unstable" ]]; then
28+
VERSION_NAME="$VERSION_GIT-next"
29+
fi
30+
2731
COMMIT=$(git log -n1 --format=format:"%H")
2832

2933
SOURCE_FILES=./cmd/mongocli
30-
PACKAGE_NAME=mongocli_${VERSION_GIT}_windows_x86_64.msi
34+
PACKAGE_NAME=mongocli_${VERSION_NAME}_windows_x86_64.msi
3135
OUTPUT=./bin/mongocli.exe
3236
LINKER_FLAGS="-s -w -X github.com/mongodb/mongodb-atlas-cli/internal/version.Version=${VERSION_GIT} -X github.com/mongodb/mongodb-atlas-cli/internal/version.GitCommit=${COMMIT} -X github.com/mongodb/mongodb-atlas-cli/internal/config.ToolName=${TOOL_NAME:?}"
3337
WIX_MANIFEST_FILE="./build/package/wix/${TOOL_NAME:?}.json"
34-
NOTARY_SIGNING_KEY=${NOTARY_SIGNING_KEY_MONGOCLI:?}
3538

3639
if [[ "${TOOL_NAME:?}" == atlascli ]]; then
37-
NOTARY_SIGNING_KEY=${NOTARY_SIGNING_KEY_ATLASCLI:?}
3840
SOURCE_FILES=./cmd/atlas
39-
PACKAGE_NAME=mongodb-atlas-cli_${VERSION_GIT}_windows_x86_64.msi
41+
PACKAGE_NAME=mongodb-atlas-cli_${VERSION_NAME}_windows_x86_64.msi
4042
OUTPUT=./bin/atlas.exe
4143
fi
4244

@@ -45,9 +47,7 @@ env GOOS=windows GOARCH=amd64 go build \
4547

4648
go-msi make --path "${WIX_MANIFEST_FILE}" --msi "dist/${PACKAGE_NAME}" --version "${VERSION_GIT}"
4749

48-
go run ./tools/sign -file "dist/${PACKAGE_NAME}"
49-
5050
if [[ "${TOOL_NAME:?}" == atlascli ]]; then
51-
go run ./tools/chocolateypkg/chocolateypkg.go -version "${VERSION_GIT}"
51+
go run ./tools/chocolateypkg/chocolateypkg.go -version "${VERSION_NAME}"
5252
choco pack dist/mongodb-atlas.nuspec --outputdirectory dist -dv
5353
fi

build/package/mongocli_windows_notarize.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

build/package/package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ VERSION_GIT="$(git tag --list "${tool_name:?}/v*" --sort=taggerdate | tail -1 |
2828

2929
if [[ "${unstable-}" == "-unstable" ]]; then
3030
# avoid race conditions on the notarization step by using `-p 1`
31-
./bin/goreleaser --config "${goreleaser_config:?}" --rm-dist --snapshot -p 1
31+
./bin/goreleaser --config "${goreleaser_config:?}" --rm-dist --release-notes "${changelog_file:?}" --snapshot -p 1
3232
else
3333
# avoid race conditions on the notarization step by using `-p 1`
3434
./bin/goreleaser --config "${goreleaser_config:?}" --rm-dist --release-notes "${changelog_file:?}" -p 1

build/package/rename-pkg.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ META_FILENAME_ARM="${meta_package_name-}_${VERSION}_linux_arm64"
2929

3030
pushd dist
3131

32+
mv ../bin/*.msi . # move msi
33+
3234
mkdir -p yum/x86_64 yum/arm64 apt/x86_64 apt/arm64
3335

3436
function rename {

0 commit comments

Comments
 (0)