diff --git a/.evergreen/release-danger-do-not-run-manually.sh b/.evergreen/release-danger-do-not-run-manually.sh index dc4e81280..bb19d8149 100755 --- a/.evergreen/release-danger-do-not-run-manually.sh +++ b/.evergreen/release-danger-do-not-run-manually.sh @@ -26,7 +26,13 @@ if [[ "${DRY_RUN}" == "yes" ]]; then fi if [[ "${PACKAGE_ONLY}" == "yes" ]]; then + pushd macros + cargo package --no-verify --allow-dirty + popd cargo package --no-verify --allow-dirty else + pushd macros + cargo publish --token $CRATES_IO_TOKEN ${EXTRA} + popd cargo publish --token $CRATES_IO_TOKEN ${EXTRA} fi diff --git a/.evergreen/release-sign.sh b/.evergreen/release-sign.sh index dba3c169e..b9fbe69b3 100644 --- a/.evergreen/release-sign.sh +++ b/.evergreen/release-sign.sh @@ -15,3 +15,11 @@ docker run \ -w $(pwd) \ artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg \ /bin/bash -c "gpgloader && gpg --yes -v --armor -o mongodb-${CRATE_VERSION}.sig --detach-sign target/package/mongodb-${CRATE_VERSION}.crate" + +docker run \ + --env-file=signing-envfile \ + --rm \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg \ + /bin/bash -c "gpgloader && gpg --yes -v --armor -o mongodb-internal-macros-${CRATE_VERSION}.sig --detach-sign macros/target/package/mongodb-internal-macros-${CRATE_VERSION}.crate" diff --git a/.evergreen/releases.yml b/.evergreen/releases.yml index 0da4a3519..ceb37e6c5 100644 --- a/.evergreen/releases.yml +++ b/.evergreen/releases.yml @@ -14,7 +14,8 @@ # # 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 +# 1. Add dummy version numbers to the Cargo.toml lines for mongodb-internal-macros, bson, +# and libmongocrypt # 2. Comment out the "fetch tag" func call from the "publish-release" task in this file # 3. Execute: # @@ -141,6 +142,7 @@ functions: version: ${CRATE_VERSION} filenames: - src/target/package/mongodb-${CRATE_VERSION}.crate + - src/macros/target/package/mongodb-internal-macros-${CRATE_VERSION}.crate "sign release": - command: subprocess.exec diff --git a/Cargo.toml b/Cargo.toml index fc3628270..c2781cf33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,7 +63,6 @@ in-use-encryption-unstable = ["dep:mongocrypt", "dep:rayon", "dep:num_cpus"] tracing-unstable = ["dep:tracing", "dep:log"] [dependencies] -action_macro = { path = "action_macro" } async-trait = "0.1.42" base64 = "0.13.0" bitflags = "1.1.0" @@ -82,6 +81,7 @@ once_cell = "1.19.0" log = { version = "0.4.17", optional = true } md-5 = "0.10.1" mongocrypt = { git = "https://github.com/mongodb/libmongocrypt-rust.git", branch = "main", optional = true } +mongodb-internal-macros = { path = "macros" } num_cpus = { version = "1.13.1", optional = true } openssl = { version = "0.10.38", optional = true } openssl-probe = { version = "0.1.5", optional = true } diff --git a/etc/update_version/src/main.rs b/etc/update_version/src/main.rs index b886652b1..d1777594c 100644 --- a/etc/update_version/src/main.rs +++ b/etc/update_version/src/main.rs @@ -74,33 +74,38 @@ struct Args { } fn main() { + // nosemgrep: current-exe + let zero = std::env::current_exe().unwrap(); + let self_dir = zero.parent().unwrap(); + let main_dir = self_dir.join("../../../.."); + std::env::set_current_dir(main_dir).unwrap(); + let version_locs = vec![ Location::new( - "../../Cargo.toml", + "Cargo.toml", r#"name = "mongodb"\nversion = "(?.*?)"\n"#, ), - Location::new("../../README.md", r#"mongodb = "(?.*?)"\n"#), Location::new( - "../../README.md", - r#"\[dependencies.mongodb\]\nversion = "(?.*?)"\n"#, + "macros/Cargo.toml", + r#"name = "mongodb-internal-macros"\nversion = "(?.*?)"\n"#, ), - Location::new("../../src/lib.rs", r#"//! mongodb = "(?.*?)"\n"#), - Location::new("../../src/lib.rs", r#"//! version = "(?.*?)"\n"#), + Location::new("README.md", r#"mongodb = "(?.*?)"\n"#), Location::new( - "../../src/lib.rs", - r#"html_root_url = "https://docs.rs/mongodb/(?.*?)""#, + "README.md", + r#"\[dependencies.mongodb\]\nversion = "(?.*?)"\n"#, ), Location::new( - "../../manual/src/installation_features.md", - r#"\[dependencies.mongodb\]\nversion = "(?.*?)"\n"#, + "src/lib.rs", + r#"html_root_url = "https://docs.rs/mongodb/(?.*?)""#, ), ]; - let bson_version_loc = - Location::new("../../Cargo.toml", r#"bson = (?\{ git = .*? \})\n"#); - let mongocrypt_version_loc = Location::new( - "../../Cargo.toml", - r#"mongocrypt = (?\{ git = .*? \})\n"#, + let quote_version_loc = Location::new( + "Cargo.toml", + r#"mongodb-internal-macros = (?\{ path = .* \})\n"#, ); + let bson_version_loc = Location::new("Cargo.toml", r#"bson = (?\{ git = .*? \})\n"#); + let mongocrypt_version_loc = + Location::new("Cargo.toml", r#"mongocrypt = (?\{ git = .*? \})\n"#); let args: Args = argh::from_env(); @@ -108,11 +113,15 @@ fn main() { for loc in &version_locs { pending.apply(loc, &args.version); } + pending.apply("e_version_loc, &format!("{:?}", args.version)); if let Some(bson) = args.bson { pending.apply(&bson_version_loc, &format!("{:?}", bson)); } if let Some(mongocrypt) = args.mongocrypt { - pending.apply(&mongocrypt_version_loc, &format!("{{ version = {:?}, optional = true }}", mongocrypt)); + pending.apply( + &mongocrypt_version_loc, + &format!("{{ version = {:?}, optional = true }}", mongocrypt), + ); } pending.write(); } diff --git a/action_macro/.gitignore b/macros/.gitignore similarity index 100% rename from action_macro/.gitignore rename to macros/.gitignore diff --git a/action_macro/Cargo.toml b/macros/Cargo.toml similarity index 86% rename from action_macro/Cargo.toml rename to macros/Cargo.toml index 5d3a69a54..43e668597 100644 --- a/action_macro/Cargo.toml +++ b/macros/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "action_macro" -version = "0.1.0" +name = "mongodb-internal-macros" +version = "2.8.0" edition = "2021" license = "Apache-2.0" diff --git a/action_macro/src/lib.rs b/macros/src/lib.rs similarity index 100% rename from action_macro/src/lib.rs rename to macros/src/lib.rs diff --git a/src/action.rs b/src/action.rs index 308c6ae38..2bb0da930 100644 --- a/src/action.rs +++ b/src/action.rs @@ -76,7 +76,7 @@ pub struct Single; #[allow(missing_docs)] pub struct Multiple; -use action_macro::option_setters; +use mongodb_internal_macros::option_setters; pub(crate) mod private { pub trait Sealed {} @@ -109,7 +109,7 @@ pub trait Action: private::Sealed + IntoFuture { } } -pub(crate) use action_macro::{action_impl, deeplink}; +pub(crate) use mongodb_internal_macros::{action_impl, deeplink}; use crate::Collection;