diff --git a/cargo-shuttle/src/lib.rs b/cargo-shuttle/src/lib.rs index 8b8c59acf..98491121c 100644 --- a/cargo-shuttle/src/lib.rs +++ b/cargo-shuttle/src/lib.rs @@ -35,7 +35,7 @@ use indoc::{formatdoc, printdoc}; use shuttle_common::{ constants::{ API_URL_DEFAULT, DEFAULT_IDLE_MINUTES, EXAMPLES_REPO, EXECUTABLE_DIRNAME, - RESOURCE_SCHEMA_VERSION, SHUTTLE_GH_ISSUE_URL, SHUTTLE_IDLE_DOCS_URL, + RESOURCE_SCHEMA_VERSION, RUNTIME_NAME, SHUTTLE_GH_ISSUE_URL, SHUTTLE_IDLE_DOCS_URL, SHUTTLE_INSTALL_DOCS_URL, SHUTTLE_LOGIN_URL, STORAGE_DIRNAME, TEMPLATES_SCHEMA_VERSION, }, deployment::{EcsState, DEPLOYER_END_MESSAGES_BAD, DEPLOYER_END_MESSAGES_GOOD}, @@ -1897,7 +1897,7 @@ impl Shuttle { // TODO: support overriding this let package = packages .first() - .expect("at least one shuttle crate in the workspace"); + .expect("Expected at least one crate with shuttle-runtime in the workspace"); let package_name = package.name.to_owned(); rust_build_args.package_name = Some(package_name); @@ -1910,6 +1910,17 @@ impl Shuttle { rust_build_args.no_default_features = no_default_features; rust_build_args.features = features.map(|v| v.join(",")); + rust_build_args.shuttle_runtime_version = package + .dependencies + .iter() + .find(|dependency| dependency.name == RUNTIME_NAME) + .expect("shuttle package to have runtime dependency") + .req + .comparators + .first() + // is "^0.X.0" when `shuttle-runtime = "0.X.0"` is in Cargo.toml + .and_then(|c| c.to_string().strip_prefix('^').map(ToOwned::to_owned)); + // TODO: determine which (one) binary to build deployment_req_buildarch_beta.build_args = Some(BuildArgsBeta::Rust(rust_build_args)); diff --git a/common/src/models/deployment.rs b/common/src/models/deployment.rs index bb14d2854..76929fcf6 100644 --- a/common/src/models/deployment.rs +++ b/common/src/models/deployment.rs @@ -303,6 +303,8 @@ pub enum BuildArgsBeta { #[derive(Deserialize, Serialize)] pub struct BuildArgsRustBeta { + /// Version of shuttle-runtime used by this crate + pub shuttle_runtime_version: Option, /// Use the built in cargo chef setup for caching pub cargo_chef: bool, /// Build with the built in `cargo build` setup @@ -322,6 +324,7 @@ pub struct BuildArgsRustBeta { impl Default for BuildArgsRustBeta { fn default() -> Self { Self { + shuttle_runtime_version: Default::default(), cargo_chef: true, cargo_build: true, package_name: Default::default(),