aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/dist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/dist.rs')
-rw-r--r--xtask/src/dist.rs23
1 files changed, 10 insertions, 13 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
10pub fn run_dist(nightly: bool) -> Result<()> { 10pub 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
22fn dist_client(nightly: bool) -> Result<()> { 22fn 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
88impl Patch { 84impl 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 }