Skip to content

Commit

Permalink
chore: fix canary version (#27723)
Browse files Browse the repository at this point in the history
Broken by
57dd66e

Closes #27719
  • Loading branch information
dsherret authored Jan 19, 2025
1 parent 57dd66e commit b962b87
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 15 deletions.
9 changes: 9 additions & 0 deletions cli/lib/build.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
16 changes: 6 additions & 10 deletions cli/lib/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,13 +38,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,
Expand All @@ -55,12 +51,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,
Expand Down Expand Up @@ -92,7 +88,7 @@ impl DenoVersionInfo {
if self.release_channel == ReleaseChannel::Canary {
self.git_hash
} else {
CARGO_PKG_VERSION
DENO_VERSION
}
}
}
1 change: 1 addition & 0 deletions cli/lib/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.6
5 changes: 3 additions & 2 deletions cli/npm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion cli/standalone/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
};

Expand Down
3 changes: 2 additions & 1 deletion cli/tools/coverage/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!(
"
<div class='footer quiet pad2 space-top1 center small'>
Expand Down
3 changes: 2 additions & 1 deletion cli/tools/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use deno_graph::EsParser;
use deno_graph::GraphKind;
use deno_graph::ModuleAnalyzer;
use deno_graph::ModuleSpecifier;
use deno_lib::version::DENO_VERSION_INFO;
use doc::html::ShortPath;
use doc::DocDiagnostic;
use indexmap::IndexMap;
Expand Down Expand Up @@ -280,7 +281,7 @@ impl deno_doc::html::HrefResolver for DocResolver {
if self.deno_ns.contains_key(symbol) {
Some(format!(
"https://deno.land/api@v{}?s={}",
env!("CARGO_PKG_VERSION"),
DENO_VERSION_INFO.deno,
symbol.join(".")
))
} else {
Expand Down
2 changes: 2 additions & 0 deletions runtime/worker_bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ impl Default for BootstrapOptions {
.map(|p| p.get())
.unwrap_or(1);

// this version is not correct as its the version of deno_runtime
// and the implementor should supply a user agent that makes sense
let runtime_version = env!("CARGO_PKG_VERSION");
let user_agent = format!("Deno/{runtime_version}");

Expand Down
2 changes: 2 additions & 0 deletions tools/release/01_bump_crate_versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const workspace = await DenoWorkspace.load();
const repo = workspace.repo;
const cliCrate = workspace.getCliCrate();
const denoRtCrate = workspace.getDenoRtCrate();
const denoLibCrate = workspace.getDenoLibCrate();
const originalCliVersion = cliCrate.version;

await bumpCiCacheVersion();
Expand All @@ -23,6 +24,7 @@ if (Deno.args.some((a) => a === "--patch")) {
}

denoRtCrate.setVersion(cliCrate.version);
denoLibCrate.folderPath.join("version.txt").writeTextSync(cliCrate.version);

// increment the dependency crate versions
for (const crate of workspace.getCliDependencyCrates()) {
Expand Down
4 changes: 4 additions & 0 deletions tools/release/deno_workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export class DenoWorkspace {
return this.getCrate("denort");
}

getDenoLibCrate() {
return this.getCrate("deno_lib");
}

getCrate(name: string) {
return this.#repo.getCrate(name);
}
Expand Down

0 comments on commit b962b87

Please sign in to comment.