diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/dist.rs | 23 | ||||
-rw-r--r-- | xtask/src/main.rs | 5 |
2 files changed, 13 insertions, 15 deletions
diff --git a/xtask/src/dist.rs b/xtask/src/dist.rs index e3dddd9b1..3a14f8a63 100644 --- a/xtask/src/dist.rs +++ b/xtask/src/dist.rs | |||
@@ -7,31 +7,27 @@ use crate::{ | |||
7 | project_root, | 7 | project_root, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | pub fn run_dist(nightly: bool) -> Result<()> { | 10 | pub fn run_dist(version: &str, release_tag: &str) -> Result<()> { |
11 | let dist = project_root().join("dist"); | 11 | let dist = project_root().join("dist"); |
12 | rm_rf(&dist)?; | 12 | rm_rf(&dist)?; |
13 | fs2::create_dir_all(&dist)?; | 13 | fs2::create_dir_all(&dist)?; |
14 | 14 | ||
15 | if cfg!(target_os = "linux") { | 15 | if cfg!(target_os = "linux") { |
16 | dist_client(nightly)?; | 16 | dist_client(version, release_tag)?; |
17 | } | 17 | } |
18 | dist_server()?; | 18 | dist_server()?; |
19 | Ok(()) | 19 | Ok(()) |
20 | } | 20 | } |
21 | 21 | ||
22 | fn dist_client(nightly: bool) -> Result<()> { | 22 | fn dist_client(version: &str, release_tag: &str) -> Result<()> { |
23 | let _d = pushd("./editors/code"); | 23 | let _d = pushd("./editors/code"); |
24 | let nightly = release_tag == "nightly"; | ||
24 | 25 | ||
25 | let package_json_path = PathBuf::from("./package.json"); | 26 | let mut patch = Patch::new("./package.json")?; |
26 | let mut patch = Patch::new(package_json_path.clone())?; | ||
27 | 27 | ||
28 | let date = run!("date --utc +%Y%m%d")?; | 28 | patch |
29 | let version_suffix = if nightly { "-nightly" } else { "" }; | 29 | .replace(r#""version": "0.4.0-dev""#, &format!(r#""version": "{}""#, version)) |
30 | 30 | .replace(r#""releaseTag": "nightly""#, &format!(r#""releaseTag": "{}""#, release_tag)); | |
31 | patch.replace( | ||
32 | r#""version": "0.2.20200309-nightly""#, | ||
33 | &format!(r#""version": "0.1.{}{}""#, date, version_suffix), | ||
34 | ); | ||
35 | 31 | ||
36 | if nightly { | 32 | if nightly { |
37 | patch.replace( | 33 | patch.replace( |
@@ -86,7 +82,8 @@ struct Patch { | |||
86 | } | 82 | } |
87 | 83 | ||
88 | impl Patch { | 84 | impl Patch { |
89 | fn new(path: PathBuf) -> Result<Patch> { | 85 | fn new(path: impl Into<PathBuf>) -> Result<Patch> { |
86 | let path = path.into(); | ||
90 | let contents = fs2::read_to_string(&path)?; | 87 | let contents = fs2::read_to_string(&path)?; |
91 | Ok(Patch { path, original_contents: contents.clone(), contents }) | 88 | Ok(Patch { path, original_contents: contents.clone(), contents }) |
92 | } | 89 | } |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 7c8ea9001..aafa73610 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -103,9 +103,10 @@ FLAGS: | |||
103 | run_release(dry_run) | 103 | run_release(dry_run) |
104 | } | 104 | } |
105 | "dist" => { | 105 | "dist" => { |
106 | let nightly = args.contains("--nightly"); | 106 | let version: String = args.value_from_str("--version")?; |
107 | let release_tag: String = args.value_from_str("--tag")?; | ||
107 | args.finish()?; | 108 | args.finish()?; |
108 | run_dist(nightly) | 109 | run_dist(&version, &release_tag) |
109 | } | 110 | } |
110 | _ => { | 111 | _ => { |
111 | eprintln!( | 112 | eprintln!( |