From b962b87cfe0057601c032fac6393cfc1eee72442 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sun, 19 Jan 2025 05:19:47 -0500 Subject: [PATCH] chore: fix canary version (#27723) Broken by https://github.com/denoland/deno/commit/57dd66ec3dae2a0fe376f6a43c476dfade421c84 Closes https://github.com/denoland/deno/issues/27719 --- cli/lib/build.rs | 9 +++++++++ cli/lib/version.rs | 16 ++++++---------- cli/lib/version.txt | 1 + cli/npm/mod.rs | 5 +++-- cli/standalone/binary.rs | 2 +- cli/tools/coverage/reporter.rs | 3 ++- cli/tools/doc.rs | 3 ++- runtime/worker_bootstrap.rs | 2 ++ tools/release/01_bump_crate_versions.ts | 2 ++ tools/release/deno_workspace.ts | 4 ++++ 10 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 cli/lib/version.txt diff --git a/cli/lib/build.rs b/cli/lib/build.rs index b093009fe0..1f52e0c02a 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 2.2.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.2.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 bcb7d2c1c6..88a25dffeb 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.6.2"; -const CARGO_PKG_VERSION: &str = env!("CARGO_PKG_VERSION"); +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 @@ -38,13 +38,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, @@ -55,12 +51,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, @@ -92,7 +88,7 @@ impl DenoVersionInfo { if self.release_channel == ReleaseChannel::Canary { self.git_hash } else { - CARGO_PKG_VERSION + DENO_VERSION } } } diff --git a/cli/lib/version.txt b/cli/lib/version.txt new file mode 100644 index 0000000000..b6da51221f --- /dev/null +++ b/cli/lib/version.txt @@ -0,0 +1 @@ +2.1.6 \ No newline at end of file diff --git a/cli/npm/mod.rs b/cli/npm/mod.rs index afb3d345d7..388b007f81 100644 --- a/cli/npm/mod.rs +++ b/cli/npm/mod.rs @@ -9,6 +9,7 @@ use dashmap::DashMap; use deno_core::serde_json; use deno_core::url::Url; use deno_error::JsErrorBox; +use deno_lib::version::DENO_VERSION_INFO; use deno_npm::npm_rc::ResolvedNpmRc; use deno_npm::registry::NpmPackageInfo; use deno_resolver::npm::ByonmNpmResolverCreateOptions; @@ -182,8 +183,8 @@ pub const NPM_CONFIG_USER_AGENT_ENV_VAR: &str = "npm_config_user_agent"; pub fn get_npm_config_user_agent() -> String { format!( "deno/{} npm/? deno/{} {} {}", - env!("CARGO_PKG_VERSION"), - env!("CARGO_PKG_VERSION"), + DENO_VERSION_INFO.deno, + DENO_VERSION_INFO.deno, std::env::consts::OS, std::env::consts::ARCH ) diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index e9b0ad5e83..3e4a5e4e4c 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -255,7 +255,7 @@ impl<'a> DenoCompileBinaryWriter<'a> { format!("canary/{}/{}", DENO_VERSION_INFO.git_hash, binary_name) } _ => { - format!("release/v{}/{}", env!("CARGO_PKG_VERSION"), binary_name) + format!("release/v{}/{}", DENO_VERSION_INFO.deno, binary_name) } }; diff --git a/cli/tools/coverage/reporter.rs b/cli/tools/coverage/reporter.rs index bc6e85b47e..4f0325117c 100644 --- a/cli/tools/coverage/reporter.rs +++ b/cli/tools/coverage/reporter.rs @@ -11,6 +11,7 @@ use std::path::PathBuf; use deno_core::error::AnyError; use deno_core::url::Url; +use deno_lib::version::DENO_VERSION_INFO; use super::util; use super::CoverageReport; @@ -559,7 +560,7 @@ impl HtmlCoverageReporter { /// Creates footer part of the contents for html report. pub fn create_html_footer(&self, now: &str) -> String { - let version = env!("CARGO_PKG_VERSION"); + let version = DENO_VERSION_INFO.deno; format!( "