Skip to content

Commit 2a41197

Browse files
committed
CXX-3010 sign and upload dist tarball during release (#1136)
1 parent 7d4dca1 commit 2a41197

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

etc/garasign_dist_file.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
# Used by make_release.py.
4+
# See: https://docs.devprod.prod.corp.mongodb.com/release-tools-container-images/garasign/garasign_signing/
5+
6+
set -o errexit
7+
set -o pipefail
8+
9+
: "${1:?"missing dist_file as first argument"}"
10+
11+
# Allow customization point to use docker in place of podman.
12+
launcher="${GARASIGN_LAUNCHER:-"podman"}"
13+
14+
if ! command -v "${launcher:?}" >/dev/null; then
15+
echo "${launcher:?} is required to sign distribution tarball" 1>&2
16+
fi
17+
18+
if ! command -v gpg >/dev/null; then
19+
echo "gpg is required to verify distribution tarball signature" 1>&2
20+
fi
21+
22+
creds=~/.secrets/garasign-creds.txt
23+
24+
if [[ ! -f "${creds:?}" ]]; then
25+
echo "missing file ${creds:?}" 1>&2
26+
exit 1
27+
fi
28+
29+
# Avoid conflict/use of creds defined in the environment.
30+
unset ARTIFACTORY_USER
31+
unset ARTIFACTORY_PASSWORD
32+
unset GRS_CONFIG_USER1_USERNAME
33+
unset GRS_CONFIG_USER1_PASSWORD
34+
35+
. "${creds:?}"
36+
37+
: "${ARTIFACTORY_USER:?"missing ARTIFACTORY_USER in ${creds:?}"}"
38+
: "${ARTIFACTORY_PASSWORD:?"missing ARTIFACTORY_PASSWORD in ${creds:?}"}"
39+
: "${GRS_CONFIG_USER1_USERNAME:?"missing GRS_CONFIG_USER1_USERNAME in ${creds:?}"}"
40+
: "${GRS_CONFIG_USER1_PASSWORD:?"missing GRS_CONFIG_USER1_PASSWORD in ${creds:?}"}"
41+
42+
dist_file="${1:?}"
43+
dist_file_signed="${dist_file:?}.asc"
44+
45+
"${launcher:?}" login --password-stdin --username "${ARTIFACTORY_USER:?}" artifactory.corp.mongodb.com <<<"${ARTIFACTORY_PASSWORD:?}"
46+
47+
plugin_commands=(
48+
gpg --yes -v --armor -o "${dist_file_signed:?}" --detach-sign "${dist_file:?}"
49+
)
50+
"${launcher:?}" run \
51+
--env-file="${creds:?}" \
52+
-e "PLUGIN_COMMANDS=${plugin_commands[*]:?}" \
53+
--rm \
54+
-v "$(pwd):$(pwd)" \
55+
-w "$(pwd)" \
56+
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg
57+
58+
# Validate the signature file works as intended.
59+
keyring="$(mktemp)"
60+
curl -sS https://pgp.mongodb.com/cpp-driver.pub | gpg -q --no-default-keyring --keyring "${keyring:?}" --import -
61+
gpgv --keyring "${keyring:?}" "${dist_file_signed:?}" "${dist_file:?}"

etc/make_release.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ def release(jira_creds_file,
187187
click.echo('C++ driver distribution not built or not found...exiting!', err=True)
188188
sys.exit(1)
189189

190+
click.echo('Signing distribution...')
191+
run_shell_script(f'./.evergreen/garasign_dist_file.sh {dist_file}')
192+
click.echo('Signing distribution... done.')
193+
190194
jira_vers_dict = get_jira_project_versions(auth_jira)
191195

192196
if release_version not in jira_vers_dict.keys():
@@ -572,6 +576,9 @@ def generate_release_notes(release_version: str, changelog_contents: str) -> str
572576
- [Create an account](https://jira.mongodb.org) and login.
573577
- Navigate to the [CXX project](https://jira.mongodb.org/browse/CXX)
574578
- Click `Create`.
579+
580+
## Signature Verification
581+
Release artifacts may be verified by using the accompanying detached signature (.asc) and the cpp-driver public key obtained from https://pgp.mongodb.com.
575582
""").lstrip()
576583

577584
release_notes = "".join(lines) + "\n"
@@ -649,7 +656,9 @@ def create_github_release_draft(gh_repo,
649656
gh_release = gh_repo.create_git_release(tag=release_tag, name=release_name,
650657
message=release_notes_text, draft=True,
651658
prerelease=is_pre_release)
659+
652660
gh_release.upload_asset(dist_file)
661+
gh_release.upload_asset(dist_file + ".asc")
653662

654663
click.echo('Github release has been created. Review and publish here: {}'
655664
.format(gh_release.html_url))

etc/releasing.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,31 @@ git tag r1.2.3
9595
## Run make_release.py
9696

9797
`make_release.py` creates the distribution tarball
98-
(e.g. mongo-cxx-driver-r1.2.3.tar.gz), interacts with Jira, and drafts the
99-
release on GitHub.
98+
(e.g. mongo-cxx-driver-r1.2.3.tar.gz) and corresponding signature file (e.g.
99+
mongo-cxx-driver-r1.2.3.tar.gz.asc), interacts with Jira, and drafts the release
100+
on GitHub.
100101

101102
To see all available options, run with `--help`
102103

103104
```
104105
python ./etc/make_release.py --help
105106
```
106107

107-
It requires the following:
108+
It requires the following (note: avoid typing secrets as command-line arguments):
108109

109110
- A GitHub token. Go to the GitHub settings page
110111
[Personal Access Tokens](https://github.com/settings/tokens) and create a
111112
token. Save the token secret to `~/.secrets/github_token.txt`.
112113
- Jira OAuth credentials. Ask for these from a team member.
113114
Save it to `~/.secrets/jira_creds.txt`.
115+
- Artifactory and Garasign credentials. Save these to `~/.secrets/garasign-creds.txt` in the form:
116+
```
117+
ARTIFACTORY_USER=<username>
118+
ARTIFACTORY_PASSWORD=<password>
119+
GRS_CONFIG_USER1_USERNAME=<username>
120+
GRS_CONFIG_USER1_PASSWORD=<password>
121+
```
122+
Ask for these from a team member.
114123

115124
Run the release script with the git tag created above as an argument and
116125
`--dry-run` to test for unexpected errors.

0 commit comments

Comments
 (0)