build: Use separate version.txt file to define crate version (#29136)

This commit is contained in:
Bartek Iwańczuk 2025-05-02 16:30:03 +02:00 committed by GitHub
parent 539e41b8d4
commit 4ded37a1e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 18 additions and 12 deletions

2
Cargo.lock generated
View file

@ -2139,7 +2139,7 @@ dependencies = [
[[package]]
name = "deno_lib"
version = "2.3.1"
version = "0.20.0"
dependencies = [
"capacity_builder",
"deno_error",

View file

@ -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" }

View file

@ -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

View file

@ -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");

View file

@ -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> =
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<DenoVersionInfo> =
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,

1
cli/lib/version.txt Normal file
View file

@ -0,0 +1 @@
2.3.1