add canary versioning (#8480)

This commit is contained in:
crowlKats 2020-11-25 11:30:14 +01:00 committed by GitHub
parent 8d12653738
commit a08d2eee2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 43 additions and 22 deletions

View file

@ -127,6 +127,15 @@ jobs:
service_account_key: ${{ secrets.GCP_SA_KEY }} service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true 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 - name: Log versions
run: | run: |
node -v node -v

View file

@ -257,6 +257,10 @@ fn main() {
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap()); println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").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 c = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());

View file

@ -223,9 +223,8 @@ To evaluate code in the shell:
lazy_static! { lazy_static! {
static ref LONG_VERSION: String = format!( static ref LONG_VERSION: String = format!(
"{} ({}, {}, {})\nv8 {}\ntypescript {}", "{} ({}, {})\nv8 {}\ntypescript {}",
crate::version::DENO, crate::version::deno(),
crate::version::GIT_COMMIT_HASH,
env!("PROFILE"), env!("PROFILE"),
env!("TARGET"), env!("TARGET"),
crate::version::v8(), 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. /// Same as flags_from_vec but does not exit on error.
pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> { 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 matches = app.get_matches_from_safe(args)?;
let mut flags = Flags::default(); let mut flags = Flags::default();
@ -298,7 +298,7 @@ pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> {
Ok(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") clap::App::new("deno")
.bin_name("deno") .bin_name("deno")
.global_settings(&[ .global_settings(&[
@ -309,7 +309,7 @@ fn clap_root<'a, 'b>() -> App<'a, 'b> {
// Disable clap's auto-detection of terminal width // Disable clap's auto-detection of terminal width
.set_term_width(0) .set_term_width(0)
// Disable each subcommand having its own version. // Disable each subcommand having its own version.
.version(crate::version::DENO) .version(version)
.long_version(LONG_VERSION.as_str()) .long_version(LONG_VERSION.as_str())
.arg( .arg(
Arg::with_name("unstable") 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) { fn completions_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
let shell: &str = matches.value_of("shell").unwrap(); let shell: &str = matches.value_of("shell").unwrap();
let mut buf: Vec<u8> = vec![]; let mut buf: Vec<u8> = vec![];
clap_root().gen_completions_to( clap_root(&*crate::version::deno()).gen_completions_to(
"deno", "deno",
clap::Shell::from_str(shell).unwrap(), clap::Shell::from_str(shell).unwrap(),
&mut buf, &mut buf,

View file

@ -33,7 +33,7 @@ pub fn create_http_client(ca_file: Option<&str>) -> Result<Client, AnyError> {
let mut headers = HeaderMap::new(); let mut headers = HeaderMap::new();
headers.insert( headers.insert(
USER_AGENT, USER_AGENT,
format!("Deno/{}", version::DENO).parse().unwrap(), format!("Deno/{}", version::deno()).parse().unwrap(),
); );
let mut builder = Client::builder() let mut builder = Client::builder()
.redirect(Policy::none()) .redirect(Policy::none())

View file

@ -201,7 +201,7 @@ async fn server(
let json_version_route = warp::path!("json" / "version").map(|| { let json_version_route = warp::path!("json" / "version").map(|| {
warp::reply::json(&json!({ warp::reply::json(&json!({
"Browser": format!("Deno/{}", crate::version::DENO), "Browser": format!("Deno/{}", crate::version::deno()),
"Protocol-Version": "1.3", "Protocol-Version": "1.3",
"V8-Version": crate::version::v8(), "V8-Version": crate::version::v8(),
})) }))

View file

@ -319,7 +319,7 @@ impl Module {
/// version. /// version.
pub fn is_emit_valid(&self, config: &[u8]) -> bool { pub fn is_emit_valid(&self, config: &[u8]) -> bool {
if let Some(version) = self.maybe_version.clone() { 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 { } else {
false false
} }
@ -484,7 +484,8 @@ impl Module {
/// Calculate the hashed version of the module and update the `maybe_version`. /// Calculate the hashed version of the module and update the `maybe_version`.
pub fn set_version(&mut self, config: &[u8]) { 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 { pub fn size(&self) -> usize {
@ -781,7 +782,7 @@ impl Graph {
let root_names = self.get_root_names(!config.get_check_js()); let root_names = self.get_root_names(!config.get_check_js());
let maybe_tsbuildinfo = self.maybe_tsbuildinfo.clone(); let maybe_tsbuildinfo = self.maybe_tsbuildinfo.clone();
let hash_data = 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 graph = Rc::new(RefCell::new(self));
let response = tsc::exec( let response = tsc::exec(
@ -904,7 +905,7 @@ impl Graph {
let root_names = self.get_root_names(!config.get_check_js()); let root_names = self.get_root_names(!config.get_check_js());
let hash_data = 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 graph = Rc::new(RefCell::new(self));
let response = tsc::exec( let response = tsc::exec(
@ -1844,7 +1845,7 @@ pub mod tests {
#[test] #[test]
fn test_module_emit_valid() { fn test_module_emit_valid() {
let source = "console.log(42);".to_string(); 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 { let module = Module {
source, source,
maybe_version, maybe_version,
@ -1854,7 +1855,7 @@ pub mod tests {
let source = "console.log(42);".to_string(); let source = "console.log(42);".to_string();
let old_source = "console.log(43);"; 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 { let module = Module {
source, source,
maybe_version, maybe_version,
@ -1882,7 +1883,7 @@ pub mod tests {
#[test] #[test]
fn test_module_set_version() { fn test_module_set_version() {
let source = "console.log(42);".to_string(); 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 { let mut module = Module {
source, source,
..Module::default() ..Module::default()

View file

@ -34,7 +34,7 @@ fn op_start(
Ok(json!({ Ok(json!({
"args": gs.flags.argv.clone(), "args": gs.flags.argv.clone(),
"debugFlag": gs.flags.log_level.map_or(false, |l| l == log::Level::Debug), "debugFlag": gs.flags.log_level.map_or(false, |l| l == log::Level::Debug),
"denoVersion": version::DENO, "denoVersion": version::deno(),
"noColor": !colors::use_color(), "noColor": !colors::use_color(),
"pid": std::process::id(), "pid": std::process::id(),
"ppid": ppid(), "ppid": ppid(),

View file

@ -467,7 +467,7 @@ pub async fn run(
.load_history(history_file.to_str().unwrap()) .load_history(history_file.to_str().unwrap())
.unwrap_or(()); .unwrap_or(());
println!("Deno {}", crate::version::DENO); println!("Deno {}", crate::version::deno());
println!("exit using ctrl+d or close()"); println!("exit using ctrl+d or close()");
inject_prelude(&mut worker, &mut session, context_id).await?; inject_prelude(&mut worker, &mut session, context_id).await?;

View file

@ -38,7 +38,8 @@ pub async fn upgrade_command(
let install_version = match version { let install_version = match version {
Some(passed_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); println!("Version {} is already installed", passed_version);
return Ok(()); return Ok(());
} else { } else {
@ -48,7 +49,7 @@ pub async fn upgrade_command(
None => { None => {
let latest_version = get_latest_version(&client).await?; 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) { let latest = match semver_parse(&latest_version) {
Ok(v) => v, Ok(v) => v,
Err(_) => { Err(_) => {
@ -60,7 +61,7 @@ pub async fn upgrade_command(
if !force && output.is_none() && current >= latest { if !force && output.is_none() && current >= latest {
println!( println!(
"Local deno version {} is the most recent release", "Local deno version {} is the most recent release",
crate::version::DENO crate::version::deno()
); );
return Ok(()); return Ok(());
} else { } else {

View file

@ -1,9 +1,15 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // 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 GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH");
pub const TYPESCRIPT: &str = crate::js::TS_VERSION; 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 { pub fn v8() -> &'static str {
deno_core::v8_version() deno_core::v8_version()
} }