Skip to content

Commit 4b1d8c2

Browse files
authored
CXX-3010 sign and upload dist tarball during release (#1136)
1 parent bdbed3e commit 4b1d8c2

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():
@@ -573,6 +577,9 @@ def generate_release_notes(release_version: str, changelog_contents: str) -> str
573577
- [Create an account](https://jira.mongodb.org) and login.
574578
- Navigate to the [CXX project](https://jira.mongodb.org/browse/CXX)
575579
- Click `Create`.
580+
581+
## Signature Verification
582+
Release artifacts may be verified by using the accompanying detached signature (.asc) and the cpp-driver public key obtained from https://pgp.mongodb.com.
576583
""").lstrip()
577584

578585
release_notes = "".join(lines) + "\n"
@@ -650,7 +657,9 @@ def create_github_release_draft(gh_repo,
650657
gh_release = gh_repo.create_git_release(tag=release_tag, name=release_name,
651658
message=release_notes_text, draft=True,
652659
prerelease=is_pre_release)
660+
653661
gh_release.upload_asset(dist_file)
662+
gh_release.upload_asset(dist_file + ".asc")
654663

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

etc/releasing.md

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

138138
`make_release.py` creates the distribution tarball
139-
(e.g. mongo-cxx-driver-r1.2.3.tar.gz), interacts with Jira, and drafts the
140-
release on GitHub.
139+
(e.g. mongo-cxx-driver-r1.2.3.tar.gz) and corresponding signature file (e.g.
140+
mongo-cxx-driver-r1.2.3.tar.gz.asc), interacts with Jira, and drafts the release
141+
on GitHub.
141142

142143
To see all available options, run with `--help`
143144

144145
```
145146
python ./etc/make_release.py --help
146147
```
147148

148-
It requires the following:
149+
It requires the following (note: avoid typing secrets as command-line arguments):
149150

150151
- A GitHub token. Go to the GitHub settings page
151152
[Personal Access Tokens](https://github.com/settings/tokens) and create a
152153
token. Save the token secret to `~/.secrets/github_token.txt`.
153154
- Jira OAuth credentials. Ask for these from a team member.
154155
Save it to `~/.secrets/jira_creds.txt`.
156+
- Artifactory and Garasign credentials. Save these to `~/.secrets/garasign-creds.txt` in the form:
157+
```
158+
ARTIFACTORY_USER=<username>
159+
ARTIFACTORY_PASSWORD=<password>
160+
GRS_CONFIG_USER1_USERNAME=<username>
161+
GRS_CONFIG_USER1_PASSWORD=<password>
162+
```
163+
Ask for these from a team member.
155164

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

0 commit comments

Comments
 (0)