Skip to content

Commit 25a2d7b

Browse files
authored
feat: Sign release packages (#23)
* sign packages and Windows binary * leftover
1 parent c4722c9 commit 25a2d7b

File tree

4 files changed

+101
-6
lines changed

4 files changed

+101
-6
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,19 @@ jobs:
5151
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
5252
VERSION: ${{ inputs.version_number }}
5353
run: make generate-all-manifests
54+
- name: Log in to MongoDB Docker registry
55+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
56+
with:
57+
registry: ${{ secrets.ARTIFACTORY_REGISTRY }}
58+
username: ${{ secrets.ARTIFACTORY_USER }}
59+
password: ${{ secrets.ARTIFACTORY_PASSWORD }}
5460
- name: Run GoReleaser
5561
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3
5662
with:
5763
args: release --clean
5864
env:
5965
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
AUTHENTICODE_KEY_NAME: ${{ secrets.AUTHENTICODE_KEY_NAME }}
67+
ARTIFACTORY_REGISTRY: ${{ secrets.ARTIFACTORY_REGISTRY }}
68+
ARTIFACTORY_SIGN_USER: ${{ secrets.ARTIFACTORY_SIGN_USER }}
69+
ARTIFACTORY_SIGN_PASSWORD: ${{ secrets.ARTIFACTORY_SIGN_PASSWORD }}

.goreleaser.yaml

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,68 @@ project_name: atlas-cli-plugin-terraform
33

44
version: 2
55

6+
before:
7+
hooks:
8+
- curl https://pgp.mongodb.com/atlas-cli.asc -o signature.asc
9+
610
builds:
7-
- id: "atlas-cli-plugin-terraform"
8-
main: ./cmd/plugin/main.go
9-
binary: ./binary
11+
- id: linux
12+
goos: [linux]
13+
goarch: [amd64, arm64]
14+
<<: &build_defaults
15+
binary: ./binary
16+
main: ./cmd/plugin
17+
- id: macos
18+
goos: [darwin]
19+
goarch: [amd64, arm64]
20+
<<: *build_defaults
21+
- id: windows
22+
goos: [windows]
23+
goarch: [amd64]
24+
goamd64: [v1]
25+
<<: *build_defaults
26+
hooks:
27+
post: # Notarize the Windows binary replacing the one created by goreleaser
28+
- cmd: ./scripts/windows_notarize.sh
29+
output: true
1030

1131
archives:
12-
- files:
13-
- src: './bin/manifest{{ if eq .Os "windows" }}.windows{{end}}.yml'
14-
dst: ./manifest.yml
32+
- id: linux
33+
builds: [linux]
34+
<<: &archive_defaults
35+
files:
36+
- src: './bin/manifest{{ if eq .Os "windows" }}.windows{{end}}.yml'
37+
dst: ./manifest.yml
38+
- id: macos
39+
builds: [macos]
40+
<<: *archive_defaults
41+
- id: windows
42+
builds: [windows]
43+
<<: *archive_defaults
44+
45+
signs:
46+
- id: all_artifacts
47+
signature: "${artifact}.sig"
48+
cmd: "./scripts/notarize.sh"
49+
ids:
50+
- linux
51+
- macos
52+
- windows
53+
artifacts: all
54+
output: true
1555

1656
release:
1757
prerelease: auto
58+
extra_files:
59+
- glob: ./*.asc
60+
61+
gomod: # https://goreleaser.com/customization/verifiable_builds/
62+
# Proxy a module from proxy.golang.org, making the builds verifiable.
63+
# This will only be effective if running against a tag. Snapshots will ignore
64+
# this setting.
65+
# Notice: for this to work your `build.main` must be a package, not a `.go` file.
66+
proxy: false
67+
# Sets the `-mod` flag value.
68+
#
69+
# Since: v1.7
70+
mod: mod

scripts/notarize.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeou pipefail
4+
5+
if [[ -f "${artifact:?}" ]]; then
6+
echo "notarizing package ${artifact}"
7+
8+
docker run \
9+
-e GRS_CONFIG_USER1_USERNAME="${ARTIFACTORY_SIGN_USER}" \
10+
-e GRS_CONFIG_USER1_PASSWORD="${ARTIFACTORY_SIGN_PASSWORD}" \
11+
--rm -v "$(pwd)":"$(pwd)" -w "$(pwd)" \
12+
"${ARTIFACTORY_REGISTRY}/release-tools-container-registry-local/garasign-gpg" \
13+
/bin/bash -c "gpgloader && gpg --yes -v --armor -o ${artifact}.sig --detach-sign ${artifact}"
14+
fi
15+
16+
echo "Signing of ${artifact} completed."

scripts/windows_notarize.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeou pipefail
4+
5+
EXE_FILE="./dist/windows_windows_amd64_v1/binary.exe"
6+
7+
if [[ -f "$EXE_FILE" ]]; then
8+
echo "signing Windows binary: ${EXE_FILE}"
9+
10+
docker run \
11+
-e GRS_CONFIG_USER1_USERNAME="${ARTIFACTORY_SIGN_USER}" \
12+
-e GRS_CONFIG_USER1_PASSWORD="${ARTIFACTORY_SIGN_PASSWORD}" \
13+
--rm -v "$(pwd)":"$(pwd)" -w "$(pwd)" \
14+
"${ARTIFACTORY_REGISTRY}/release-tools-container-registry-local/garasign-jsign" \
15+
/bin/bash -c "jsign --tsaurl http://timestamp.digicert.com -a ${AUTHENTICODE_KEY_NAME} \"${EXE_FILE}\""
16+
fi

0 commit comments

Comments
 (0)