diff options
Diffstat (limited to 'xtask/src/dist.rs')
-rw-r--r-- | xtask/src/dist.rs | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index f2503f807..12a7fea1e 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs | |||
@@ -7,26 +7,31 @@ use std::{ | |||
7 | 7 | ||
8 | use anyhow::Result; | 8 | use anyhow::Result; |
9 | use flate2::{write::GzEncoder, Compression}; | 9 | use flate2::{write::GzEncoder, Compression}; |
10 | use xshell::{cmd, cp, mkdir_p, pushd, read_file, rm_rf, write_file}; | 10 | use xshell::{cmd, cp, mkdir_p, pushd, pushenv, read_file, rm_rf, write_file}; |
11 | 11 | ||
12 | use crate::{date_iso, project_root}; | 12 | use crate::{date_iso, flags, project_root}; |
13 | 13 | ||
14 | pub(crate) struct DistCmd { | 14 | impl flags::Dist { |
15 | pub(crate) nightly: bool, | ||
16 | pub(crate) client_version: Option<String>, | ||
17 | } | ||
18 | |||
19 | impl DistCmd { | ||
20 | pub(crate) fn run(self) -> Result<()> { | 15 | pub(crate) fn run(self) -> Result<()> { |
16 | let stable = | ||
17 | std::env::var("GITHUB_REF").unwrap_or_default().as_str() == "refs/heads/release"; | ||
18 | |||
21 | let dist = project_root().join("dist"); | 19 | let dist = project_root().join("dist"); |
22 | rm_rf(&dist)?; | 20 | rm_rf(&dist)?; |
23 | mkdir_p(&dist)?; | 21 | mkdir_p(&dist)?; |
24 | 22 | ||
25 | if let Some(version) = self.client_version { | 23 | if let Some(patch_version) = self.client_patch_version { |
26 | let release_tag = if self.nightly { "nightly".to_string() } else { date_iso()? }; | 24 | let version = if stable { |
25 | format!("0.2.{}", patch_version) | ||
26 | } else { | ||
27 | // A hack to make VS Code prefer nightly over stable. | ||
28 | format!("0.3.{}", patch_version) | ||
29 | }; | ||
30 | let release_tag = if stable { date_iso()? } else { "nightly".to_string() }; | ||
27 | dist_client(&version, &release_tag)?; | 31 | dist_client(&version, &release_tag)?; |
28 | } | 32 | } |
29 | dist_server()?; | 33 | let release_channel = if stable { "stable" } else { "nightly" }; |
34 | dist_server(release_channel)?; | ||
30 | Ok(()) | 35 | Ok(()) |
31 | } | 36 | } |
32 | } | 37 | } |
@@ -39,7 +44,9 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> { | |||
39 | 44 | ||
40 | patch | 45 | patch |
41 | .replace(r#""version": "0.4.0-dev""#, &format!(r#""version": "{}""#, version)) | 46 | .replace(r#""version": "0.4.0-dev""#, &format!(r#""version": "{}""#, version)) |
42 | .replace(r#""releaseTag": null"#, &format!(r#""releaseTag": "{}""#, release_tag)); | 47 | .replace(r#""releaseTag": null"#, &format!(r#""releaseTag": "{}""#, release_tag)) |
48 | .replace(r#""$generated-start": false,"#, "") | ||
49 | .replace(",\n \"$generated-end\": false", ""); | ||
43 | 50 | ||
44 | if nightly { | 51 | if nightly { |
45 | patch.replace( | 52 | patch.replace( |
@@ -57,7 +64,8 @@ fn dist_client(version: &str, release_tag: &str) -> Result<()> { | |||
57 | Ok(()) | 64 | Ok(()) |
58 | } | 65 | } |
59 | 66 | ||
60 | fn dist_server() -> Result<()> { | 67 | fn dist_server(release_channel: &str) -> Result<()> { |
68 | let _e = pushenv("RUST_ANALYZER_CHANNEL", release_channel); | ||
61 | let target = get_target(); | 69 | let target = get_target(); |
62 | if target.contains("-linux-gnu") || target.contains("-linux-musl") { | 70 | if target.contains("-linux-gnu") || target.contains("-linux-musl") { |
63 | env::set_var("CC", "clang"); | 71 | env::set_var("CC", "clang"); |