From 869ec5f97ace736fdbf765d143c9634fd1b558ef Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 26 Apr 2021 15:17:02 +0300 Subject: fix: dont' misundentify nightly as stable in --version on Mac&Win We used to set `--nightly` in CI, and only for linux. Let's detect this in xtask instead. --- xtask/src/dist.rs | 24 ++++++++++++++---------- xtask/src/flags.rs | 9 ++------- xtask/src/main.rs | 6 +----- 3 files changed, 17 insertions(+), 22 deletions(-) (limited to 'xtask') diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index d1c005954..12a7fea1e 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs @@ -9,24 +9,28 @@ use anyhow::Result; use flate2::{write::GzEncoder, Compression}; use xshell::{cmd, cp, mkdir_p, pushd, pushenv, read_file, rm_rf, write_file}; -use crate::{date_iso, project_root}; +use crate::{date_iso, flags, project_root}; -pub(crate) struct DistCmd { - pub(crate) nightly: bool, - pub(crate) client_version: Option, -} - -impl DistCmd { +impl flags::Dist { pub(crate) fn run(self) -> Result<()> { + let stable = + std::env::var("GITHUB_REF").unwrap_or_default().as_str() == "refs/heads/release"; + let dist = project_root().join("dist"); rm_rf(&dist)?; mkdir_p(&dist)?; - if let Some(version) = self.client_version { - let release_tag = if self.nightly { "nightly".to_string() } else { date_iso()? }; + if let Some(patch_version) = self.client_patch_version { + let version = if stable { + format!("0.2.{}", patch_version) + } else { + // A hack to make VS Code prefer nightly over stable. + format!("0.3.{}", patch_version) + }; + let release_tag = if stable { date_iso()? } else { "nightly".to_string() }; dist_client(&version, &release_tag)?; } - let release_channel = if self.nightly { "nightly" } else { "stable" }; + let release_channel = if stable { "stable" } else { "nightly" }; dist_server(release_channel)?; Ok(()) } diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs index 4cd2b1ddb..f80a5dd16 100644 --- a/xtask/src/flags.rs +++ b/xtask/src/flags.rs @@ -37,8 +37,7 @@ xflags::xflags! { optional --dry-run } cmd dist { - optional --nightly - optional --client version: String + optional --client-patch-version version: String } cmd metrics { optional --dry-run @@ -85,9 +84,6 @@ pub struct Install { pub jemalloc: bool, } -#[derive(Debug)] -pub struct Lint; - #[derive(Debug)] pub struct FuzzTests; @@ -106,8 +102,7 @@ pub struct Promote { #[derive(Debug)] pub struct Dist { - pub nightly: bool, - pub client: Option, + pub client_patch_version: Option, } #[derive(Debug)] diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 960927fc0..e0e620c76 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -28,8 +28,6 @@ use std::{ use walkdir::{DirEntry, WalkDir}; use xshell::{cmd, cp, pushd, pushenv}; -use crate::dist::DistCmd; - fn main() -> Result<()> { let _d = pushd(project_root())?; @@ -44,9 +42,7 @@ fn main() -> Result<()> { flags::XtaskCmd::PreCache(cmd) => cmd.run(), flags::XtaskCmd::Release(cmd) => cmd.run(), flags::XtaskCmd::Promote(cmd) => cmd.run(), - flags::XtaskCmd::Dist(flags) => { - DistCmd { nightly: flags.nightly, client_version: flags.client }.run() - } + flags::XtaskCmd::Dist(cmd) => cmd.run(), flags::XtaskCmd::Metrics(cmd) => cmd.run(), flags::XtaskCmd::Bb(cmd) => { { -- cgit v1.2.3