mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
add canary versioning (#8480)
This commit is contained in:
parent
8d12653738
commit
a08d2eee2b
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -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
|
||||
|
@ -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());
|
||||
|
14
cli/flags.rs
14
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,
|
||||
|
@ -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())
|
||||
|
@ -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(),
|
||||
}))
|
||||
|
@ -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()
|
||||
|
@ -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(),
|
||||
|
@ -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?;
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user