From 4ded37a1e7099a33f08aaf1ba8f9d88ac725ec4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 2 May 2025 16:30:03 +0200 Subject: [PATCH] build: Use separate `version.txt` file to define crate version (#29136) --- Cargo.lock | 2 +- Cargo.toml | 2 +- cli/lib/Cargo.toml | 2 +- cli/lib/build.rs | 9 +++++++++ cli/lib/version.rs | 14 +++++--------- cli/lib/version.txt | 1 + 6 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 cli/lib/version.txt diff --git a/Cargo.lock b/Cargo.lock index c4b7e47f81..31f6f05aac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2139,7 +2139,7 @@ dependencies = [ [[package]] name = "deno_lib" -version = "2.3.1" +version = "0.20.0" dependencies = [ "capacity_builder", "deno_error", diff --git a/Cargo.toml b/Cargo.toml index 53849b9a99..beefbce144 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,7 +110,7 @@ denort_helper = { version = "0.2.0", path = "./ext/rt_helper" } # workspace libraries deno_bench_util = { version = "0.198.0", path = "./bench_util" } deno_features = { version = "0.1.0", path = "./runtime/features" } -deno_lib = { version = "2.3.1", path = "./cli/lib" } +deno_lib = { version = "0.20.0", path = "./cli/lib" } deno_npm_cache = { version = "0.23.0", path = "./resolvers/npm_cache" } deno_permissions = { version = "0.63.0", path = "./runtime/permissions" } deno_resolver = { version = "0.35.0", path = "./resolvers/deno" } diff --git a/cli/lib/Cargo.toml b/cli/lib/Cargo.toml index 999c76e43d..9f9c963932 100644 --- a/cli/lib/Cargo.toml +++ b/cli/lib/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "deno_lib" -version = "2.3.1" +version = "0.20.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/cli/lib/build.rs b/cli/lib/build.rs index b093009fe0..685a8dbd9a 100644 --- a/cli/lib/build.rs +++ b/cli/lib/build.rs @@ -1,6 +1,15 @@ // Copyright 2018-2025 the Deno authors. MIT license. fn main() { + // todo(dsherret): remove this after Deno 242.0 is published and then + // align the version of this crate with Deno then. We need to wait because + // there was previously a deno_lib 2.4.0 published (https://crates.io/crates/deno_lib/versions) + let version_path = std::path::Path::new(".").join("version.txt"); + println!("cargo:rerun-if-changed={}", version_path.display()); + #[allow(clippy::disallowed_methods)] + let text = std::fs::read_to_string(version_path).unwrap(); + println!("cargo:rustc-env=DENO_VERSION={}", text); + let commit_hash = git_commit_hash(); println!("cargo:rustc-env=GIT_COMMIT_HASH={}", commit_hash); println!("cargo:rerun-if-env-changed=GIT_COMMIT_HASH"); diff --git a/cli/lib/version.rs b/cli/lib/version.rs index 8c894d8366..5fca80aea0 100644 --- a/cli/lib/version.rs +++ b/cli/lib/version.rs @@ -15,7 +15,7 @@ pub fn otel_runtime_config() -> OtelRuntimeConfig { const GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH"); const TYPESCRIPT: &str = "5.8.3"; -pub const DENO_VERSION: &str = env!("CARGO_PKG_VERSION"); +pub const DENO_VERSION: &str = env!("DENO_VERSION"); // TODO(bartlomieju): ideally we could remove this const. const IS_CANARY: bool = option_env!("DENO_CANARY").is_some(); // TODO(bartlomieju): this is temporary, to allow Homebrew to cut RC releases as well @@ -40,13 +40,9 @@ pub static DENO_VERSION_INFO: std::sync::LazyLock = DenoVersionInfo { deno: if release_channel == ReleaseChannel::Canary { - concat!( - env!("CARGO_PKG_VERSION"), - "+", - env!("GIT_COMMIT_HASH_SHORT") - ) + concat!(env!("DENO_VERSION"), "+", env!("GIT_COMMIT_HASH_SHORT")) } else { - env!("CARGO_PKG_VERSION") + env!("DENO_VERSION") }, release_channel, @@ -57,12 +53,12 @@ pub static DENO_VERSION_INFO: std::sync::LazyLock = user_agent: if release_channel == ReleaseChannel::Canary { concat!( "Deno/", - env!("CARGO_PKG_VERSION"), + env!("DENO_VERSION"), "+", env!("GIT_COMMIT_HASH_SHORT") ) } else { - concat!("Deno/", env!("CARGO_PKG_VERSION")) + concat!("Deno/", env!("DENO_VERSION")) }, typescript: TYPESCRIPT, diff --git a/cli/lib/version.txt b/cli/lib/version.txt new file mode 100644 index 0000000000..2bf1c1ccf3 --- /dev/null +++ b/cli/lib/version.txt @@ -0,0 +1 @@ +2.3.1