Skip to content

Commit e7edf97

Browse files
authored
ci: Setup signing packages (#25)
* Initial package sig * Clean-up * Adds to readme and releasing markdowns * Renumber list
1 parent 91b2598 commit e7edf97

File tree

6 files changed

+76
-3
lines changed

6 files changed

+76
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Atlas CLI Kubernetes Plugin
2+
3+
The Atlas CLI Kubernetes Plugin is a first class plugin, providing kubernetes commands for the MongoDB Atlas CLI.

RELEASING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ git push origin "v1.0.0"
1515

1616
This will do the following things:
1717
1. The [evergreen](build/ci/release.yml) release task will run after a tag event from main.
18-
2. If everything goes smoothly, the release will be published in the [releases page](https://github.com/mongodb/atlas-cli-plugin-kubernetes/releases).
19-
3. The [evergreen](build/ci/release.yml) copybara task will automatically open a PR on docs repositories with any document changes for the docs team to review and merge.
18+
2. This task signs all packages and includes both them and the public key in the release.
19+
3. If everything goes smoothly, the release will be published in the [releases page](https://github.com/mongodb/atlas-cli-plugin-kubernetes/releases).
20+
4. The [evergreen](build/ci/release.yml) copybara task will automatically open a PR on docs repositories with any document changes for the docs team to review and merge.

build/ci/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,17 @@ functions:
6969
<<: *go_options
7070
env:
7171
<<: *go_env
72+
ARTIFACTORY_USERNAME: ${artifactory_username}
73+
ARTIFACTORY_PASSWORD: ${artifactory_password}
74+
GRS_USERNAME: ${garasign_username}
75+
GRS_PASSWORD: ${garasign_password}
7276
GITHUB_TOKEN: ${github_token}
7377
include_expansions_in_env:
7478
- go_base_path
7579
- workdir
80+
- notary_service_key_id
81+
- notary_service_secret
82+
- notary_service_url
7683
- goreleaser_key
7784
- version
7885
binary: build/package/package.sh

build/package/.goreleaser.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ project_name: atlas-cli-plugin-kubernetes
33

44
version: 2
55

6+
before:
7+
hooks:
8+
- go mod tidy
9+
- curl https://pgp.mongodb.com/atlas-cli.asc -o atlas-cli.asc
10+
611
builds:
712
- <<: &build_defaults
813
env:
@@ -35,7 +40,7 @@ gomod: # https://goreleaser.com/customization/verifiable_builds/
3540
mod: mod
3641

3742
archives:
38-
- id: linux_archives
43+
- id: linux
3944
name_template: atlas-cli-plugin-kubernetes_{{ .Version }}_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }}
4045
builds: [linux]
4146
<<: &archive_defaults
@@ -61,6 +66,18 @@ archives:
6166
format: zip
6267
checksum:
6368
name_template: checksums.txt
69+
signs:
70+
- id: all_artifacts
71+
signature: "${artifact}.sig"
72+
cmd: "./build/package/notarize.sh"
73+
ids:
74+
- linux
75+
- macos
76+
- windows
77+
artifacts: all
78+
output: true
6479
release:
6580
prerelease: auto
6681
name_template: "Atlas CLI Plugin Kubernetes v{{.Version}}"
82+
extra_files:
83+
- glob: ./*.asc

build/package/notarize.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 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 generates the detached sign of all packages via garasign-gpg.
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 part of a custom publisher.
22+
23+
echo "GRS_CONFIG_USER1_USERNAME=${GRS_USERNAME}" >> "signing-envfile"
24+
echo "GRS_CONFIG_USER1_PASSWORD=${GRS_PASSWORD}" >> "signing-envfile"
25+
26+
if [[ -f "${artifact:?}" ]]; then
27+
echo "${ARTIFACTORY_PASSWORD}" | podman login --password-stdin --username "${ARTIFACTORY_USERNAME}" artifactory.corp.mongodb.com
28+
29+
echo "notarizing package ${artifact}"
30+
31+
podman run \
32+
--env-file=signing-envfile \
33+
--rm \
34+
-v "$(pwd)":"$(pwd)" \
35+
-w "$(pwd)" \
36+
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg \
37+
/bin/bash -c "gpgloader && gpg --yes -v --armor -o ${artifact}.sig --detach-sign ${artifact}"
38+
fi
39+
40+
echo "Signing of ${artifact} completed."
41+

build/package/package.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
set -Eeou pipefail
1818

1919
export GOROOT="${GOROOT:?}"
20+
21+
export NOTARY_SERVICE_URL=${notary_service_url:?}
22+
export MACOS_NOTARY_KEY=${notary_service_key_id:?}
23+
export MACOS_NOTARY_SECRET=${notary_service_secret:?}
2024
export GORELEASER_KEY=${goreleaser_key:?}
2125
export VERSION_GIT=${version:?}
2226
VERSION=$(git tag --list 'v*' --sort=-taggerdate | head -1 | cut -d 'v' -f 2)

0 commit comments

Comments
 (0)