Skip to content

Commit 9040625

Browse files
authored
RUST-1932 Integrate release process with papertrail (#1090)
1 parent 7b66c3b commit 9040625

File tree

5 files changed

+133
-22
lines changed

5 files changed

+133
-22
lines changed

.evergreen/config.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,12 +1511,19 @@ functions:
15111511
.evergreen/run-plain-tests.sh
15121512
15131513
"prepare resources":
1514+
- command: subprocess.exec
1515+
params:
1516+
working_dir: src
1517+
include_expansions_in_env:
1518+
- DRIVERS_TOOLS
1519+
binary: bash
1520+
args:
1521+
- .evergreen/fetch-drivers-tools.sh
1522+
15141523
- command: shell.exec
15151524
params:
15161525
script: |
15171526
${PREPARE_SHELL}
1518-
rm -rf $DRIVERS_TOOLS
1519-
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
15201527
echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
15211528
15221529
"install rust":

.evergreen/fetch-drivers-tools.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
if [[ -z "$DRIVERS_TOOLS" ]]; then
6+
echo >&2 "\$DRIVERS_TOOLS must be set"
7+
exit 1
8+
fi
9+
10+
rm -rf $DRIVERS_TOOLS
11+
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set +x
5+
6+
. ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/rust
7+
rm secrets-export.sh
8+
9+
PAPERTRAIL_PRODUCT="rust-driver"
10+
if [[ "${DRY_RUN}" == "yes" ]]; then
11+
PAPERTRAIL_PRODUCT="rust-driver-testing"
12+
fi
13+
14+
cat <<EOT >papertrail-expansion.yml
15+
PAPERTRAIL_KEY_ID: "${PAPERTRAIL_KEY_ID}"
16+
PAPERTRAIL_SECRET_KEY: "${PAPERTRAIL_SECRET_KEY}"
17+
PAPERTRAIL_PRODUCT: "${PAPERTRAIL_PRODUCT}"
18+
EOT

.evergreen/release-danger-do-not-run-manually.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ set +x
1313

1414
set -o errexit
1515

16-
if [[ -z "$TOKEN" ]]; then
17-
echo >&2 "\$TOKEN must be set to the crates.io authentication token"
16+
if [[ -z "$CRATES_IO_TOKEN" ]]; then
17+
echo >&2 "\$CRATES_IO_TOKEN must be set to the crates.io authentication token"
1818
exit 1
1919
fi
2020

@@ -25,4 +25,8 @@ if [[ "${DRY_RUN}" == "yes" ]]; then
2525
EXTRA="--dry-run"
2626
fi
2727

28-
cargo publish --token $TOKEN ${EXTRA}
28+
if [[ "${PACKAGE_ONLY}" == "yes" ]]; then
29+
cargo package --no-verify --allow-dirty
30+
else
31+
cargo publish --token $CRATES_IO_TOKEN ${EXTRA}
32+
fi

.evergreen/releases.yml

Lines changed: 88 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
## Testing changes to this file
2+
#
3+
# You'll need to know the git tag of the most recent release; call that ${TAG}.
4+
#
5+
# The simplest way is to develop changes as a branch from the most recent release;
6+
# in that case, a release dry-run can be executed via:
7+
#
8+
# evergreen patch --path .evergreen/releases.yml \
9+
# -t publish-release -v all \
10+
# -p mongo-rust-driver-current \
11+
# -u --browse \
12+
# --param triggered_by_git_tag=${TAG} \
13+
# --param DRY_RUN=yes
14+
#
15+
# If the changes need to be developed against the main branch, more steps are needed:
16+
#
17+
# 1. Add dummy version numbers to the Cargo.toml lines for action_macro, bson, and libmongocrypt
18+
# 2. Comment out the "fetch tag" func call from the "publish-release" task in this file
19+
# 3. Execute:
20+
#
21+
# evergreen patch --path .evergreen/releases.yml \
22+
# -t publish-release -v all \
23+
# -p mongo-rust-driver \
24+
# -u --browse \
25+
# --param triggered_by_git_tag=${TAG} \
26+
# --param DRY_RUN=yes \
27+
# --param PACKAGE_ONLY=yes
28+
#
29+
# Make sure to remove the changes from 1 and 2 before merging!
30+
31+
132
exec_timeout_secs: 3600
233

334
functions:
@@ -12,9 +43,12 @@ functions:
1243
working_dir: "src"
1344
script: |
1445
export PROJECT_DIRECTORY="$(pwd)"
46+
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
1547
1648
cat <<EOT > expansion.yml
49+
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
1750
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
51+
GIT_TAG: "${triggered_by_git_tag}"
1852
PREPARE_SHELL: |
1953
set -o errexit
2054
set -o xtrace
@@ -40,45 +74,82 @@ functions:
4074
rm expansion.yml
4175
4276
"install dependencies":
43-
command: shell.exec
44-
params:
45-
working_dir: "src"
46-
script: |
47-
${PREPARE_SHELL}
48-
.evergreen/install-dependencies.sh rust
77+
- command: shell.exec
78+
params:
79+
working_dir: "src"
80+
script: |
81+
${PREPARE_SHELL}
82+
.evergreen/install-dependencies.sh rust
83+
84+
- command: subprocess.exec
85+
params:
86+
working_dir: src
87+
include_expansions_in_env:
88+
- DRIVERS_TOOLS
89+
binary: bash
90+
args:
91+
- .evergreen/fetch-drivers-tools.sh
92+
93+
"build papertrail vars":
94+
- command: subprocess.exec
95+
params:
96+
working_dir: src
97+
include_expansions_in_env:
98+
- DRIVERS_TOOLS
99+
- DRY_RUN
100+
- GIT_TAG
101+
binary: bash
102+
args:
103+
- .evergreen/release-build-papertrail-vars.sh
104+
105+
- command: expansions.update
106+
params:
107+
file: src/papertrail-expansion.yml
108+
109+
- command: shell.exec
110+
params:
111+
working_dir: "src"
112+
script: rm papertrail-expansion.yml
49113

50114
"fetch tag":
51115
command: subprocess.exec
52116
params:
53117
working_dir: "src"
54-
add_expansions_to_env: true
118+
include_expansions_in_env:
119+
- GIT_TAG
55120
binary: bash
56121
args:
57122
- .evergreen/release-fetch-tag.sh
58123

59124
"publish release":
60-
- command: shell.exec
125+
- command: subprocess.exec
61126
type: test
62127
params:
63128
working_dir: "src"
64-
script: |
65-
set +x
129+
add_expansions_to_env: true
130+
binary: bash
131+
args:
132+
- .evergreen/release-danger-do-not-run-manually.sh
66133

67-
TAG=${GIT_TAG} \
68-
TOKEN=${CRATES_IO_TOKEN} \
69-
DRY_RUN=${DRY_RUN} \
70-
PROJECT_DIRECTORY="$(pwd)" \
71-
bash .evergreen/release-danger-do-not-run-manually.sh
134+
"publish papertrail":
135+
- command: papertrail.trace
136+
params:
137+
key_id: ${PAPERTRAIL_KEY_ID}
138+
secret_key: ${PAPERTRAIL_SECRET_KEY}
139+
product: ${PAPERTRAIL_PRODUCT}
140+
version: ${GIT_TAG}
141+
filenames:
142+
- src/target/package/mongodb-*.crate
72143

73144
tasks:
74145
- name: "publish-release"
75146
commands:
76147
- func: "fetch source"
77148
- func: "install dependencies"
78149
- func: "fetch tag"
79-
vars:
80-
GIT_TAG: ${triggered_by_git_tag}
150+
- func: "build papertrail vars"
81151
- func: "publish release"
152+
- func: "publish papertrail"
82153

83154
axes:
84155
- id: "os"

0 commit comments

Comments
 (0)