diff --git a/.evergreen/config.yml b/.evergreen/config.yml index b9ba9c0d9..2a5f7f2b2 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1511,12 +1511,19 @@ functions: .evergreen/run-plain-tests.sh "prepare resources": + - command: subprocess.exec + params: + working_dir: src + include_expansions_in_env: + - DRIVERS_TOOLS + binary: bash + args: + - .evergreen/fetch-drivers-tools.sh + - command: shell.exec params: script: | ${PREPARE_SHELL} - rm -rf $DRIVERS_TOOLS - git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config "install rust": diff --git a/.evergreen/fetch-drivers-tools.sh b/.evergreen/fetch-drivers-tools.sh new file mode 100755 index 000000000..aa5abe9fa --- /dev/null +++ b/.evergreen/fetch-drivers-tools.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -o errexit + +if [[ -z "$DRIVERS_TOOLS" ]]; then + echo >&2 "\$DRIVERS_TOOLS must be set" + exit 1 +fi + +rm -rf $DRIVERS_TOOLS +git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS diff --git a/.evergreen/release-build-papertrail-vars.sh b/.evergreen/release-build-papertrail-vars.sh new file mode 100644 index 000000000..7e64f2bf8 --- /dev/null +++ b/.evergreen/release-build-papertrail-vars.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -o errexit +set +x + +. ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/rust +rm secrets-export.sh + +PAPERTRAIL_PRODUCT="rust-driver" +if [[ "${DRY_RUN}" == "yes" ]]; then + PAPERTRAIL_PRODUCT="rust-driver-testing" +fi + +cat <papertrail-expansion.yml +PAPERTRAIL_KEY_ID: "${PAPERTRAIL_KEY_ID}" +PAPERTRAIL_SECRET_KEY: "${PAPERTRAIL_SECRET_KEY}" +PAPERTRAIL_PRODUCT: "${PAPERTRAIL_PRODUCT}" +EOT diff --git a/.evergreen/release-danger-do-not-run-manually.sh b/.evergreen/release-danger-do-not-run-manually.sh index 1846dbef5..dc4e81280 100755 --- a/.evergreen/release-danger-do-not-run-manually.sh +++ b/.evergreen/release-danger-do-not-run-manually.sh @@ -13,8 +13,8 @@ set +x set -o errexit -if [[ -z "$TOKEN" ]]; then - echo >&2 "\$TOKEN must be set to the crates.io authentication token" +if [[ -z "$CRATES_IO_TOKEN" ]]; then + echo >&2 "\$CRATES_IO_TOKEN must be set to the crates.io authentication token" exit 1 fi @@ -25,4 +25,8 @@ if [[ "${DRY_RUN}" == "yes" ]]; then EXTRA="--dry-run" fi -cargo publish --token $TOKEN ${EXTRA} +if [[ "${PACKAGE_ONLY}" == "yes" ]]; then + cargo package --no-verify --allow-dirty +else + cargo publish --token $CRATES_IO_TOKEN ${EXTRA} +fi diff --git a/.evergreen/releases.yml b/.evergreen/releases.yml index af5477f8d..3fba2263f 100644 --- a/.evergreen/releases.yml +++ b/.evergreen/releases.yml @@ -1,3 +1,34 @@ +## Testing changes to this file +# +# You'll need to know the git tag of the most recent release; call that ${TAG}. +# +# The simplest way is to develop changes as a branch from the most recent release; +# in that case, a release dry-run can be executed via: +# +# evergreen patch --path .evergreen/releases.yml \ +# -t publish-release -v all \ +# -p mongo-rust-driver-current \ +# -u --browse \ +# --param triggered_by_git_tag=${TAG} \ +# --param DRY_RUN=yes +# +# If the changes need to be developed against the main branch, more steps are needed: +# +# 1. Add dummy version numbers to the Cargo.toml lines for action_macro, bson, and libmongocrypt +# 2. Comment out the "fetch tag" func call from the "publish-release" task in this file +# 3. Execute: +# +# evergreen patch --path .evergreen/releases.yml \ +# -t publish-release -v all \ +# -p mongo-rust-driver \ +# -u --browse \ +# --param triggered_by_git_tag=${TAG} \ +# --param DRY_RUN=yes \ +# --param PACKAGE_ONLY=yes +# +# Make sure to remove the changes from 1 and 2 before merging! + + exec_timeout_secs: 3600 functions: @@ -12,9 +43,12 @@ functions: working_dir: "src" script: | export PROJECT_DIRECTORY="$(pwd)" + export DRIVERS_TOOLS="$(pwd)/../drivers-tools" cat < expansion.yml + DRIVERS_TOOLS: "$DRIVERS_TOOLS" PROJECT_DIRECTORY: "$PROJECT_DIRECTORY" + GIT_TAG: "${triggered_by_git_tag}" PREPARE_SHELL: | set -o errexit set -o xtrace @@ -40,35 +74,72 @@ functions: rm expansion.yml "install dependencies": - command: shell.exec - params: - working_dir: "src" - script: | - ${PREPARE_SHELL} - .evergreen/install-dependencies.sh rust + - command: shell.exec + params: + working_dir: "src" + script: | + ${PREPARE_SHELL} + .evergreen/install-dependencies.sh rust + + - command: subprocess.exec + params: + working_dir: src + include_expansions_in_env: + - DRIVERS_TOOLS + binary: bash + args: + - .evergreen/fetch-drivers-tools.sh + + "build papertrail vars": + - command: subprocess.exec + params: + working_dir: src + include_expansions_in_env: + - DRIVERS_TOOLS + - DRY_RUN + - GIT_TAG + binary: bash + args: + - .evergreen/release-build-papertrail-vars.sh + + - command: expansions.update + params: + file: src/papertrail-expansion.yml + + - command: shell.exec + params: + working_dir: "src" + script: rm papertrail-expansion.yml "fetch tag": command: subprocess.exec params: working_dir: "src" - add_expansions_to_env: true + include_expansions_in_env: + - GIT_TAG binary: bash args: - .evergreen/release-fetch-tag.sh "publish release": - - command: shell.exec + - command: subprocess.exec type: test params: working_dir: "src" - script: | - set +x + add_expansions_to_env: true + binary: bash + args: + - .evergreen/release-danger-do-not-run-manually.sh - TAG=${GIT_TAG} \ - TOKEN=${CRATES_IO_TOKEN} \ - DRY_RUN=${DRY_RUN} \ - PROJECT_DIRECTORY="$(pwd)" \ - bash .evergreen/release-danger-do-not-run-manually.sh + "publish papertrail": + - command: papertrail.trace + params: + key_id: ${PAPERTRAIL_KEY_ID} + secret_key: ${PAPERTRAIL_SECRET_KEY} + product: ${PAPERTRAIL_PRODUCT} + version: ${GIT_TAG} + filenames: + - src/target/package/mongodb-*.crate tasks: - name: "publish-release" @@ -76,9 +147,9 @@ tasks: - func: "fetch source" - func: "install dependencies" - func: "fetch tag" - vars: - GIT_TAG: ${triggered_by_git_tag} + - func: "build papertrail vars" - func: "publish release" + - func: "publish papertrail" axes: - id: "os"