diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/dist.rs | 34 | ||||
-rw-r--r-- | xtask/src/flags.rs | 9 | ||||
-rw-r--r-- | xtask/src/main.rs | 8 | ||||
-rw-r--r-- | xtask/src/release.rs | 11 |
4 files changed, 35 insertions, 27 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"); |
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! { | |||
37 | optional --dry-run | 37 | optional --dry-run |
38 | } | 38 | } |
39 | cmd dist { | 39 | cmd dist { |
40 | optional --nightly | 40 | optional --client-patch-version version: String |
41 | optional --client version: String | ||
42 | } | 41 | } |
43 | cmd metrics { | 42 | cmd metrics { |
44 | optional --dry-run | 43 | optional --dry-run |
@@ -86,9 +85,6 @@ pub struct Install { | |||
86 | } | 85 | } |
87 | 86 | ||
88 | #[derive(Debug)] | 87 | #[derive(Debug)] |
89 | pub struct Lint; | ||
90 | |||
91 | #[derive(Debug)] | ||
92 | pub struct FuzzTests; | 88 | pub struct FuzzTests; |
93 | 89 | ||
94 | #[derive(Debug)] | 90 | #[derive(Debug)] |
@@ -106,8 +102,7 @@ pub struct Promote { | |||
106 | 102 | ||
107 | #[derive(Debug)] | 103 | #[derive(Debug)] |
108 | pub struct Dist { | 104 | pub struct Dist { |
109 | pub nightly: bool, | 105 | pub client_patch_version: Option<String>, |
110 | pub client: Option<String>, | ||
111 | } | 106 | } |
112 | 107 | ||
113 | #[derive(Debug)] | 108 | #[derive(Debug)] |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 960927fc0..ce3353410 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -28,8 +28,6 @@ use std::{ | |||
28 | use walkdir::{DirEntry, WalkDir}; | 28 | use walkdir::{DirEntry, WalkDir}; |
29 | use xshell::{cmd, cp, pushd, pushenv}; | 29 | use xshell::{cmd, cp, pushd, pushenv}; |
30 | 30 | ||
31 | use crate::dist::DistCmd; | ||
32 | |||
33 | fn main() -> Result<()> { | 31 | fn main() -> Result<()> { |
34 | let _d = pushd(project_root())?; | 32 | let _d = pushd(project_root())?; |
35 | 33 | ||
@@ -44,9 +42,7 @@ fn main() -> Result<()> { | |||
44 | flags::XtaskCmd::PreCache(cmd) => cmd.run(), | 42 | flags::XtaskCmd::PreCache(cmd) => cmd.run(), |
45 | flags::XtaskCmd::Release(cmd) => cmd.run(), | 43 | flags::XtaskCmd::Release(cmd) => cmd.run(), |
46 | flags::XtaskCmd::Promote(cmd) => cmd.run(), | 44 | flags::XtaskCmd::Promote(cmd) => cmd.run(), |
47 | flags::XtaskCmd::Dist(flags) => { | 45 | flags::XtaskCmd::Dist(cmd) => cmd.run(), |
48 | DistCmd { nightly: flags.nightly, client_version: flags.client }.run() | ||
49 | } | ||
50 | flags::XtaskCmd::Metrics(cmd) => cmd.run(), | 46 | flags::XtaskCmd::Metrics(cmd) => cmd.run(), |
51 | flags::XtaskCmd::Bb(cmd) => { | 47 | flags::XtaskCmd::Bb(cmd) => { |
52 | { | 48 | { |
@@ -112,7 +108,7 @@ fn run_fuzzer() -> Result<()> { | |||
112 | } | 108 | } |
113 | 109 | ||
114 | fn date_iso() -> Result<String> { | 110 | fn date_iso() -> Result<String> { |
115 | let res = cmd!("date --iso --utc").read()?; | 111 | let res = cmd!("date -u +%Y-%m-%d").read()?; |
116 | Ok(res) | 112 | Ok(res) |
117 | } | 113 | } |
118 | 114 | ||
diff --git a/xtask/src/release.rs b/xtask/src/release.rs index 22bb50467..452f351d0 100644 --- a/xtask/src/release.rs +++ b/xtask/src/release.rs | |||
@@ -10,7 +10,16 @@ impl flags::Release { | |||
10 | cmd!("git switch release").run()?; | 10 | cmd!("git switch release").run()?; |
11 | cmd!("git fetch upstream --tags --force").run()?; | 11 | cmd!("git fetch upstream --tags --force").run()?; |
12 | cmd!("git reset --hard tags/nightly").run()?; | 12 | cmd!("git reset --hard tags/nightly").run()?; |
13 | cmd!("git push").run()?; | 13 | // The `release` branch sometimes has a couple of cherry-picked |
14 | // commits for patch releases. If that's the case, just overwrite | ||
15 | // it. As we are setting `release` branch to an up-to-date `nightly` | ||
16 | // tag, this shouldn't be problematic in general. | ||
17 | // | ||
18 | // Note that, as we tag releases, we don't worry about "losing" | ||
19 | // commits -- they'll be kept alive by the tag. More generally, we | ||
20 | // don't care about historic releases all that much, it's fine even | ||
21 | // to delete old tags. | ||
22 | cmd!("git push --force").run()?; | ||
14 | } | 23 | } |
15 | codegen::docs()?; | 24 | codegen::docs()?; |
16 | 25 | ||