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. --- .github/workflows/release.yaml | 7 +------ xtask/src/dist.rs | 24 ++++++++++++++---------- xtask/src/flags.rs | 9 ++------- xtask/src/main.rs | 6 +----- 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 307096ef3..b50ca9a6f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -109,12 +109,7 @@ jobs: node-version: 12.x - name: Dist - if: github.ref == 'refs/heads/release' - run: cargo xtask dist --client 0.2.$GITHUB_RUN_NUMBER - - - name: Dist - if: github.ref != 'refs/heads/release' - run: cargo xtask dist --nightly --client 0.3.$GITHUB_RUN_NUMBER-nightly + run: cargo xtask dist --client-patch-version $GITHUB_RUN_NUMBER - name: Run analysis-stats on rust-analyzer run: target/${{ env.RA_TARGET }}/release/rust-analyzer analysis-stats . 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