Skip to content

Commit d3cc97e

Browse files
authored
RUST-1934 Publish internal macros as their own crate (#1109)
1 parent 91a91e2 commit d3cc97e

File tree

9 files changed

+47
-22
lines changed

9 files changed

+47
-22
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ if [[ "${DRY_RUN}" == "yes" ]]; then
2626
fi
2727

2828
if [[ "${PACKAGE_ONLY}" == "yes" ]]; then
29+
pushd macros
30+
cargo package --no-verify --allow-dirty
31+
popd
2932
cargo package --no-verify --allow-dirty
3033
else
34+
pushd macros
35+
cargo publish --token $CRATES_IO_TOKEN ${EXTRA}
36+
popd
3137
cargo publish --token $CRATES_IO_TOKEN ${EXTRA}
3238
fi

.evergreen/release-sign.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ docker run \
1515
-w $(pwd) \
1616
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg \
1717
/bin/bash -c "gpgloader && gpg --yes -v --armor -o mongodb-${CRATE_VERSION}.sig --detach-sign target/package/mongodb-${CRATE_VERSION}.crate"
18+
19+
docker run \
20+
--env-file=signing-envfile \
21+
--rm \
22+
-v $(pwd):$(pwd) \
23+
-w $(pwd) \
24+
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg \
25+
/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"

.evergreen/releases.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#
1515
# If the changes need to be developed against the main branch, more steps are needed:
1616
#
17-
# 1. Add dummy version numbers to the Cargo.toml lines for action_macro, bson, and libmongocrypt
17+
# 1. Add dummy version numbers to the Cargo.toml lines for mongodb-internal-macros, bson,
18+
# and libmongocrypt
1819
# 2. Comment out the "fetch tag" func call from the "publish-release" task in this file
1920
# 3. Execute:
2021
#
@@ -141,6 +142,7 @@ functions:
141142
version: ${CRATE_VERSION}
142143
filenames:
143144
- src/target/package/mongodb-${CRATE_VERSION}.crate
145+
- src/macros/target/package/mongodb-internal-macros-${CRATE_VERSION}.crate
144146

145147
"sign release":
146148
- command: subprocess.exec

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ in-use-encryption-unstable = ["dep:mongocrypt", "dep:rayon", "dep:num_cpus"]
6363
tracing-unstable = ["dep:tracing", "dep:log"]
6464

6565
[dependencies]
66-
action_macro = { path = "action_macro" }
6766
async-trait = "0.1.42"
6867
base64 = "0.13.0"
6968
bitflags = "1.1.0"
@@ -82,6 +81,7 @@ once_cell = "1.19.0"
8281
log = { version = "0.4.17", optional = true }
8382
md-5 = "0.10.1"
8483
mongocrypt = { git = "https://github.com/mongodb/libmongocrypt-rust.git", branch = "main", optional = true }
84+
mongodb-internal-macros = { path = "macros" }
8585
num_cpus = { version = "1.13.1", optional = true }
8686
openssl = { version = "0.10.38", optional = true }
8787
openssl-probe = { version = "0.1.5", optional = true }

etc/update_version/src/main.rs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,45 +74,54 @@ struct Args {
7474
}
7575

7676
fn main() {
77+
// nosemgrep: current-exe
78+
let zero = std::env::current_exe().unwrap();
79+
let self_dir = zero.parent().unwrap();
80+
let main_dir = self_dir.join("../../../..");
81+
std::env::set_current_dir(main_dir).unwrap();
82+
7783
let version_locs = vec![
7884
Location::new(
79-
"../../Cargo.toml",
85+
"Cargo.toml",
8086
r#"name = "mongodb"\nversion = "(?<target>.*?)"\n"#,
8187
),
82-
Location::new("../../README.md", r#"mongodb = "(?<target>.*?)"\n"#),
8388
Location::new(
84-
"../../README.md",
85-
r#"\[dependencies.mongodb\]\nversion = "(?<target>.*?)"\n"#,
89+
"macros/Cargo.toml",
90+
r#"name = "mongodb-internal-macros"\nversion = "(?<target>.*?)"\n"#,
8691
),
87-
Location::new("../../src/lib.rs", r#"//! mongodb = "(?<target>.*?)"\n"#),
88-
Location::new("../../src/lib.rs", r#"//! version = "(?<target>.*?)"\n"#),
92+
Location::new("README.md", r#"mongodb = "(?<target>.*?)"\n"#),
8993
Location::new(
90-
"../../src/lib.rs",
91-
r#"html_root_url = "https://docs.rs/mongodb/(?<target>.*?)""#,
94+
"README.md",
95+
r#"\[dependencies.mongodb\]\nversion = "(?<target>.*?)"\n"#,
9296
),
9397
Location::new(
94-
"../../manual/src/installation_features.md",
95-
r#"\[dependencies.mongodb\]\nversion = "(?<target>.*?)"\n"#,
98+
"src/lib.rs",
99+
r#"html_root_url = "https://docs.rs/mongodb/(?<target>.*?)""#,
96100
),
97101
];
98-
let bson_version_loc =
99-
Location::new("../../Cargo.toml", r#"bson = (?<target>\{ git = .*? \})\n"#);
100-
let mongocrypt_version_loc = Location::new(
101-
"../../Cargo.toml",
102-
r#"mongocrypt = (?<target>\{ git = .*? \})\n"#,
102+
let quote_version_loc = Location::new(
103+
"Cargo.toml",
104+
r#"mongodb-internal-macros = (?<target>\{ path = .* \})\n"#,
103105
);
106+
let bson_version_loc = Location::new("Cargo.toml", r#"bson = (?<target>\{ git = .*? \})\n"#);
107+
let mongocrypt_version_loc =
108+
Location::new("Cargo.toml", r#"mongocrypt = (?<target>\{ git = .*? \})\n"#);
104109

105110
let args: Args = argh::from_env();
106111

107112
let mut pending = PendingUpdates::new();
108113
for loc in &version_locs {
109114
pending.apply(loc, &args.version);
110115
}
116+
pending.apply(&quote_version_loc, &format!("{:?}", args.version));
111117
if let Some(bson) = args.bson {
112118
pending.apply(&bson_version_loc, &format!("{:?}", bson));
113119
}
114120
if let Some(mongocrypt) = args.mongocrypt {
115-
pending.apply(&mongocrypt_version_loc, &format!("{{ version = {:?}, optional = true }}", mongocrypt));
121+
pending.apply(
122+
&mongocrypt_version_loc,
123+
&format!("{{ version = {:?}, optional = true }}", mongocrypt),
124+
);
116125
}
117126
pending.write();
118127
}
File renamed without changes.

action_macro/Cargo.toml renamed to macros/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "action_macro"
3-
version = "0.1.0"
2+
name = "mongodb-internal-macros"
3+
version = "2.8.0"
44
edition = "2021"
55
license = "Apache-2.0"
66

File renamed without changes.

src/action.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub struct Single;
7676
#[allow(missing_docs)]
7777
pub struct Multiple;
7878

79-
use action_macro::option_setters;
79+
use mongodb_internal_macros::option_setters;
8080

8181
pub(crate) mod private {
8282
pub trait Sealed {}
@@ -109,7 +109,7 @@ pub trait Action: private::Sealed + IntoFuture {
109109
}
110110
}
111111

112-
pub(crate) use action_macro::{action_impl, deeplink};
112+
pub(crate) use mongodb_internal_macros::{action_impl, deeplink};
113113

114114
use crate::Collection;
115115

0 commit comments

Comments
 (0)