Skip to content

Commit e45a609

Browse files
authored
CXX-3002 update release instructions to support signed release tags (#1388)
* Update garasign-gpg before usage * Use GNUPGHOME for garasign_dist_file.sh * Fix detection of C Driver v2 header files * Fix typo of --skip-distcheck flag * Silence shellcheck warnings
1 parent f6fef68 commit e45a609

File tree

4 files changed

+103
-33
lines changed

4 files changed

+103
-33
lines changed

etc/garasign_dist_file.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ artifactory_creds=~/.secrets/artifactory-creds.txt
2323
garasign_creds=~/.secrets/garasign-creds.txt
2424

2525
unset ARTIFACTORY_USER ARTIFACTORY_PASSWORD
26+
# shellcheck source=/dev/null
2627
. "${artifactory_creds:?}"
2728
: "${ARTIFACTORY_USER:?"missing ARTIFACTORY_USER in ${artifactory_creds:?}"}"
2829
: "${ARTIFACTORY_PASSWORD:?"missing ARTIFACTORY_PASSWORD in ${artifactory_creds:?}"}"
2930

3031
unset GRS_CONFIG_USER1_USERNAME GRS_CONFIG_USER1_PASSWORD
32+
# shellcheck source=/dev/null
3133
. "${garasign_creds:?}"
3234
: "${GRS_CONFIG_USER1_USERNAME:?"missing GRS_CONFIG_USER1_USERNAME in ${garasign_creds:?}"}"
3335
: "${GRS_CONFIG_USER1_PASSWORD:?"missing GRS_CONFIG_USER1_PASSWORD in ${garasign_creds:?}"}"
@@ -37,6 +39,9 @@ dist_file_signed="${dist_file:?}.asc"
3739

3840
"${launcher:?}" login --password-stdin --username "${ARTIFACTORY_USER:?}" artifactory.corp.mongodb.com <<<"${ARTIFACTORY_PASSWORD:?}"
3941

42+
# Ensure latest version of Garasign is being used.
43+
"${launcher:?}" pull artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg
44+
4045
plugin_commands=(
4146
gpg --yes -v --armor -o "${dist_file_signed:?}" --detach-sign "${dist_file:?}"
4247
)
@@ -49,6 +54,9 @@ plugin_commands=(
4954
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg
5055

5156
# Validate the signature file works as intended.
52-
keyring="$(mktemp)"
53-
curl -sS https://pgp.mongodb.com/cpp-driver.pub | gpg -q --no-default-keyring --keyring "${keyring:?}" --import -
54-
gpgv --keyring "${keyring:?}" "${dist_file_signed:?}" "${dist_file:?}"
57+
(
58+
GNUPGHOME="$(mktemp -d)"
59+
export GNUPGHOME
60+
curl -sS https://pgp.mongodb.com/cpp-driver.pub | gpg -q --no-default-keyring --import -
61+
gpgv "${dist_file_signed:?}" "${dist_file:?}"
62+
)

etc/garasign_release_tag.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 tag name as first argument"}"
10+
11+
release_tag="${1:?}"
12+
13+
# Allow customization point to use docker in place of podman.
14+
launcher="${GARASIGN_LAUNCHER:-"podman"}"
15+
16+
if ! command -v "${launcher:?}" >/dev/null; then
17+
echo "${launcher:?} is required to create a GPG-signed release tag" 1>&2
18+
fi
19+
20+
artifactory_creds=~/.secrets/artifactory-creds.txt
21+
garasign_creds=~/.secrets/garasign-creds.txt
22+
23+
unset ARTIFACTORY_USER ARTIFACTORY_PASSWORD
24+
# shellcheck source=/dev/null
25+
. "${artifactory_creds:?}"
26+
: "${ARTIFACTORY_USER:?"missing ARTIFACTORY_USER in ${artifactory_creds:?}"}"
27+
: "${ARTIFACTORY_PASSWORD:?"missing ARTIFACTORY_PASSWORD in ${artifactory_creds:?}"}"
28+
29+
unset GRS_CONFIG_USER1_USERNAME GRS_CONFIG_USER1_PASSWORD
30+
# shellcheck source=/dev/null
31+
. "${garasign_creds:?}"
32+
: "${GRS_CONFIG_USER1_USERNAME:?"missing GRS_CONFIG_USER1_USERNAME in ${garasign_creds:?}"}"
33+
: "${GRS_CONFIG_USER1_PASSWORD:?"missing GRS_CONFIG_USER1_PASSWORD in ${garasign_creds:?}"}"
34+
35+
"${launcher:?}" login --password-stdin --username "${ARTIFACTORY_USER:?}" artifactory.corp.mongodb.com <<<"${ARTIFACTORY_PASSWORD:?}"
36+
37+
# Ensure latest version of Garasign is being used.
38+
"${launcher:?}" pull artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-git
39+
40+
# Sign using "MongoDB C++ Release Signing Key <[email protected]>" from https://pgp.mongodb.com/ (cpp-driver).
41+
git_tag_command=(
42+
git
43+
-c "user.name=\"MongoDB C++ Release Signing Key\""
44+
-c "user.email=\"[email protected]\""
45+
tag
46+
-u DC7F679B8A34DD606C1E54CAC4FC994D21532195
47+
-m "\"${release_tag:?}\""
48+
"\"${release_tag:?}\""
49+
)
50+
plugin_commands=""
51+
plugin_commands+="gpg --list-key DC7F679B8A34DD606C1E54CAC4FC994D21532195"
52+
plugin_commands+="&& ${git_tag_command[*]:?}"
53+
"${launcher:?}" run \
54+
--env-file="${garasign_creds:?}" \
55+
-e "PLUGIN_COMMANDS=${plugin_commands:?}" \
56+
--rm \
57+
-v "$(pwd):$(pwd)" \
58+
-w "$(pwd)" \
59+
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-git
60+
61+
# Validate the release tag is signed as intended.
62+
(
63+
GNUPGHOME="$(mktemp -d)"
64+
export GNUPGHOME
65+
curl -sS https://pgp.mongodb.com/cpp-driver.pub | gpg -q --no-default-keyring --import -
66+
git verify-tag "${release_tag:?}"
67+
)

etc/make_release.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import re
4242
from distutils.version import LooseVersion
4343
import os
44+
import glob
4445
import subprocess
4546
import sys
4647
import tempfile
@@ -68,6 +69,9 @@
6869
}
6970

7071
@click.command()
72+
@click.option('--skip-release-tag',
73+
is_flag=True,
74+
help='Use an existing release tag instead of creating a new one')
7175
@click.option('--jira-creds-file',
7276
'-j',
7377
default='jira_creds.txt',
@@ -111,7 +115,8 @@
111115
help='Produce fewer progress messages')
112116
@click.argument('git-revision', required=True)
113117
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
114-
def release(jira_creds_file,
118+
def release(skip_release_tag,
119+
jira_creds_file,
115120
github_token_file,
116121
allow_open_issues,
117122
remote,
@@ -148,6 +153,13 @@ def release(jira_creds_file,
148153
if not quiet:
149154
print_banner(git_revision)
150155

156+
if skip_release_tag:
157+
click.echo(f'Skipping creation of a new release tag')
158+
else:
159+
click.echo('Creating GPG-signed release tag...')
160+
run_shell_script(f'./etc/garasign_release_tag.sh {git_revision}')
161+
click.echo('Creating GPG-signed release tag... done.')
162+
151163
release_tag, release_version = get_release_tag(git_revision)
152164

153165
if not release_tag:
@@ -384,9 +396,9 @@ def ensure_c_driver(c_driver_build_ref, with_c_driver, quiet):
384396
"""
385397

386398
if with_c_driver:
387-
bson_h = os.path.join(with_c_driver, 'include/bson2/bson/bson.h')
388-
mongoc_h = os.path.join(with_c_driver, 'include/mongoc2/mongoc/mongoc.h')
389-
if os.path.exists(bson_h) and os.path.exists(mongoc_h):
399+
bson_h = glob.glob('include/bson-2.*/bson/bson.h', root_dir=with_c_driver)
400+
mongoc_h = glob.glob('include/mongoc-2.*/mongoc/mongoc.h', root_dir=with_c_driver)
401+
if bson_h and mongoc_h:
390402
return with_c_driver
391403
if not quiet:
392404
click.echo('A required component of the C driver is missing!', err=True)
@@ -452,7 +464,7 @@ def build_distribution(release_tag, release_version, c_driver_dir, quiet, skip_d
452464

453465
if not skip_distcheck:
454466
click.echo('Building C++ driver from tarball and running tests.')
455-
click.echo('This may take several minutes. This may be skipped with --skip_distcheck')
467+
click.echo('This may take several minutes. This may be skipped with --skip-distcheck')
456468
run_shell_script('cmake --build build --target distcheck')
457469
return dist_file
458470

etc/releasing.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ git clone -o upstream [email protected]:mongodb/mongo-cxx-driver.git mongo-cxx-driv
287287
cd mongo-cxx-driver-release
288288
```
289289

290+
> [!WARNING]
291+
> The upcoming steps may modify the state of the current repository!
292+
> Cloning the updated repository in a new directory is highly recommended.
293+
290294
Create and activate a fresh Python 3 virtual environment with required packages installed using [uv](https://docs.astral.sh/uv/getting-started/installation/):
291295

292296
```bash
@@ -300,36 +304,14 @@ uv sync --frozen --group apidocs --group make_release
300304
source "$UV_PROJECT_ENVIRONMENT/bin/activate"
301305
```
302306

303-
### Create a Release Tag...
304-
305-
> [!IMPORTANT]
306-
> Do NOT push the release tag immediately after its creation!
307-
308-
#### ... for a Patch Release
309-
310-
Checkout the release branch (containing the changes from earlier steps) and create a tag for the release.
311-
312-
```bash
313-
git checkout releases/vX.Y
314-
git tag rX.Y.Z
315-
```
316-
317-
#### ... for a Non-Patch Release
318-
319-
Checkout the `master` branch (containing the changes from earlier steps) and create a tag for the release:
320-
321-
```bash
322-
git checkout master
323-
git tag rX.Y.0
324-
```
325-
326307
> [!NOTE]
327308
> A new release branch `releases/vX.Y` will be created later as part of post-release steps.
328309
329310
### Run etc/make_release.py
330311

331312
This script performs the following steps:
332313

314+
- create a GPG-signed release tag,
333315
- create the distribution tarball (e.g. `mongo-cxx-driver-r1.2.3.tar.gz`),
334316
- creates a signature file for the distribution tarball (e.g. `mongo-cxx-driver-r1.2.3.tar.gz.asc`),
335317
- query Jira for release and ticket statuses, and
@@ -348,7 +330,7 @@ The following secrets are required by this script:
348330
- Artifactory credentials.
349331
- Garasign credentials.
350332

351-
Run the release script with the git tag created above as an argument and
333+
Run the release script with the name of the tag to be created as an argument and
352334
`--dry-run` to test for unexpected errors.
353335

354336
```bash
@@ -367,6 +349,7 @@ If an error occurs, inspect logs the script produces, and troubleshoot as
367349
follows:
368350

369351
- Use `--dry-run` to prevent unrecoverable effects.
352+
- Use `--skip-release-tag` to skip creating the release tag when it already exists.
370353
- If building the C driver fails, use an existing C driver build (ensure it is
371354
the right version) with `--with-c-driver /path/to/c-driver/install`.
372355
- Use `--skip-distcheck` to bypass time consuming checks when building the
@@ -380,7 +363,7 @@ Verify the successful creation of the release draft on GitHub.
380363

381364
### Push the Release Tag
382365

383-
Push the release tag (created earlier) to the remote repository:
366+
Push the newly-created GPG-signed release tag to the remote repository:
384367

385368
```bash
386369
git push upstream rX.Y.Z

0 commit comments

Comments
 (0)