summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml9
-rw-r--r--cli/build.rs4
-rw-r--r--cli/flags.rs14
-rw-r--r--cli/http_util.rs2
-rw-r--r--cli/inspector.rs2
-rw-r--r--cli/module_graph.rs15
-rw-r--r--cli/ops/runtime.rs2
-rw-r--r--cli/tools/repl.rs2
-rw-r--r--cli/tools/upgrade.rs7
-rw-r--r--cli/version.rs8
10 files changed, 43 insertions, 22 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4472df7da..089821408 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -127,6 +127,15 @@ jobs:
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
+ - name: Configure canary build
+ if: |
+ matrix.kind == 'test_release' &&
+ github.repository == 'denoland/deno' &&
+ github.ref == 'refs/heads/master'
+ shell: bash
+ run: |
+ echo "DENO_CANARY=true" >> $GITHUB_ENV
+
- name: Log versions
run: |
node -v
diff --git a/cli/build.rs b/cli/build.rs
index 48d9d378e..76cfedd8b 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -257,6 +257,10 @@ fn main() {
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
+ println!(
+ "cargo:rustc-env=DENO_CANARY={}",
+ env::var("DENO_CANARY").unwrap_or_default()
+ );
let c = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
diff --git a/cli/flags.rs b/cli/flags.rs
index 761763627..fb489bbb5 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -223,9 +223,8 @@ To evaluate code in the shell:
lazy_static! {
static ref LONG_VERSION: String = format!(
- "{} ({}, {}, {})\nv8 {}\ntypescript {}",
- crate::version::DENO,
- crate::version::GIT_COMMIT_HASH,
+ "{} ({}, {})\nv8 {}\ntypescript {}",
+ crate::version::deno(),
env!("PROFILE"),
env!("TARGET"),
crate::version::v8(),
@@ -244,7 +243,8 @@ pub fn flags_from_vec(args: Vec<String>) -> Flags {
/// Same as flags_from_vec but does not exit on error.
pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> {
- let app = clap_root();
+ let version = crate::version::deno();
+ let app = clap_root(&*version);
let matches = app.get_matches_from_safe(args)?;
let mut flags = Flags::default();
@@ -298,7 +298,7 @@ pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> {
Ok(flags)
}
-fn clap_root<'a, 'b>() -> App<'a, 'b> {
+fn clap_root<'a, 'b>(version: &'b str) -> App<'a, 'b> {
clap::App::new("deno")
.bin_name("deno")
.global_settings(&[
@@ -309,7 +309,7 @@ fn clap_root<'a, 'b>() -> App<'a, 'b> {
// Disable clap's auto-detection of terminal width
.set_term_width(0)
// Disable each subcommand having its own version.
- .version(crate::version::DENO)
+ .version(version)
.long_version(LONG_VERSION.as_str())
.arg(
Arg::with_name("unstable")
@@ -430,7 +430,7 @@ fn bundle_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
fn completions_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
let shell: &str = matches.value_of("shell").unwrap();
let mut buf: Vec<u8> = vec![];
- clap_root().gen_completions_to(
+ clap_root(&*crate::version::deno()).gen_completions_to(
"deno",
clap::Shell::from_str(shell).unwrap(),
&mut buf,
diff --git a/cli/http_util.rs b/cli/http_util.rs
index 1a8fcab62..c32e0deda 100644
--- a/cli/http_util.rs
+++ b/cli/http_util.rs
@@ -33,7 +33,7 @@ pub fn create_http_client(ca_file: Option<&str>) -> Result<Client, AnyError> {
let mut headers = HeaderMap::new();
headers.insert(
USER_AGENT,
- format!("Deno/{}", version::DENO).parse().unwrap(),
+ format!("Deno/{}", version::deno()).parse().unwrap(),
);
let mut builder = Client::builder()
.redirect(Policy::none())
diff --git a/cli/inspector.rs b/cli/inspector.rs
index 4da71435f..a8be68c8d 100644
--- a/cli/inspector.rs
+++ b/cli/inspector.rs
@@ -201,7 +201,7 @@ async fn server(
let json_version_route = warp::path!("json" / "version").map(|| {
warp::reply::json(&json!({
- "Browser": format!("Deno/{}", crate::version::DENO),
+ "Browser": format!("Deno/{}", crate::version::deno()),
"Protocol-Version": "1.3",
"V8-Version": crate::version::v8(),
}))
diff --git a/cli/module_graph.rs b/cli/module_graph.rs
index 2572feb10..b6759a9d2 100644
--- a/cli/module_graph.rs
+++ b/cli/module_graph.rs
@@ -319,7 +319,7 @@ impl Module {
/// version.
pub fn is_emit_valid(&self, config: &[u8]) -> bool {
if let Some(version) = self.maybe_version.clone() {
- version == get_version(&self.source, version::DENO, config)
+ version == get_version(&self.source, &version::deno(), config)
} else {
false
}
@@ -484,7 +484,8 @@ impl Module {
/// Calculate the hashed version of the module and update the `maybe_version`.
pub fn set_version(&mut self, config: &[u8]) {
- self.maybe_version = Some(get_version(&self.source, version::DENO, config))
+ self.maybe_version =
+ Some(get_version(&self.source, &version::deno(), config))
}
pub fn size(&self) -> usize {
@@ -781,7 +782,7 @@ impl Graph {
let root_names = self.get_root_names(!config.get_check_js());
let maybe_tsbuildinfo = self.maybe_tsbuildinfo.clone();
let hash_data =
- vec![config.as_bytes(), version::DENO.as_bytes().to_owned()];
+ vec![config.as_bytes(), version::deno().as_bytes().to_owned()];
let graph = Rc::new(RefCell::new(self));
let response = tsc::exec(
@@ -904,7 +905,7 @@ impl Graph {
let root_names = self.get_root_names(!config.get_check_js());
let hash_data =
- vec![config.as_bytes(), version::DENO.as_bytes().to_owned()];
+ vec![config.as_bytes(), version::deno().as_bytes().to_owned()];
let graph = Rc::new(RefCell::new(self));
let response = tsc::exec(
@@ -1844,7 +1845,7 @@ pub mod tests {
#[test]
fn test_module_emit_valid() {
let source = "console.log(42);".to_string();
- let maybe_version = Some(get_version(&source, version::DENO, b""));
+ let maybe_version = Some(get_version(&source, &version::deno(), b""));
let module = Module {
source,
maybe_version,
@@ -1854,7 +1855,7 @@ pub mod tests {
let source = "console.log(42);".to_string();
let old_source = "console.log(43);";
- let maybe_version = Some(get_version(old_source, version::DENO, b""));
+ let maybe_version = Some(get_version(old_source, &version::deno(), b""));
let module = Module {
source,
maybe_version,
@@ -1882,7 +1883,7 @@ pub mod tests {
#[test]
fn test_module_set_version() {
let source = "console.log(42);".to_string();
- let expected = Some(get_version(&source, version::DENO, b""));
+ let expected = Some(get_version(&source, &version::deno(), b""));
let mut module = Module {
source,
..Module::default()
diff --git a/cli/ops/runtime.rs b/cli/ops/runtime.rs
index e29cf9f85..3fd73a67e 100644
--- a/cli/ops/runtime.rs
+++ b/cli/ops/runtime.rs
@@ -34,7 +34,7 @@ fn op_start(
Ok(json!({
"args": gs.flags.argv.clone(),
"debugFlag": gs.flags.log_level.map_or(false, |l| l == log::Level::Debug),
- "denoVersion": version::DENO,
+ "denoVersion": version::deno(),
"noColor": !colors::use_color(),
"pid": std::process::id(),
"ppid": ppid(),
diff --git a/cli/tools/repl.rs b/cli/tools/repl.rs
index be85dc813..e6a2fd709 100644
--- a/cli/tools/repl.rs
+++ b/cli/tools/repl.rs
@@ -467,7 +467,7 @@ pub async fn run(
.load_history(history_file.to_str().unwrap())
.unwrap_or(());
- println!("Deno {}", crate::version::DENO);
+ println!("Deno {}", crate::version::deno());
println!("exit using ctrl+d or close()");
inject_prelude(&mut worker, &mut session, context_id).await?;
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index f183540cf..3344ca2d5 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -38,7 +38,8 @@ pub async fn upgrade_command(
let install_version = match version {
Some(passed_version) => {
- if !force && output.is_none() && crate::version::DENO == passed_version {
+ if !force && output.is_none() && crate::version::deno() == passed_version
+ {
println!("Version {} is already installed", passed_version);
return Ok(());
} else {
@@ -48,7 +49,7 @@ pub async fn upgrade_command(
None => {
let latest_version = get_latest_version(&client).await?;
- let current = semver_parse(crate::version::DENO).unwrap();
+ let current = semver_parse(&*crate::version::deno()).unwrap();
let latest = match semver_parse(&latest_version) {
Ok(v) => v,
Err(_) => {
@@ -60,7 +61,7 @@ pub async fn upgrade_command(
if !force && output.is_none() && current >= latest {
println!(
"Local deno version {} is the most recent release",
- crate::version::DENO
+ crate::version::deno()
);
return Ok(());
} else {
diff --git a/cli/version.rs b/cli/version.rs
index 0f2a69a5c..70185c19e 100644
--- a/cli/version.rs
+++ b/cli/version.rs
@@ -1,9 +1,15 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-pub const DENO: &str = env!("CARGO_PKG_VERSION");
pub const GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH");
pub const TYPESCRIPT: &str = crate::js::TS_VERSION;
+pub fn deno() -> String {
+ let semver = env!("CARGO_PKG_VERSION");
+ option_env!("DENO_CANARY").map_or(semver.to_string(), |_| {
+ format!("{}-{}", semver, GIT_COMMIT_HASH)
+ })
+}
+
pub fn v8() -> &'static str {
deno_core::v8_version()
}