aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-10 14:32:03 +0000
committerAleksey Kladov <[email protected]>2020-02-10 14:34:04 +0000
commit57147d7471584e23135dff1e629a44dfd7657276 (patch)
tree514ec735d466af7257fff57c4c4740eb260accda /xtask
parent1b6acc391aee6a2c2868f537786f1dfa4ff774a2 (diff)
xtask release
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/cmd.rs1
-rw-r--r--xtask/src/lib.rs43
-rw-r--r--xtask/src/main.rs6
3 files changed, 48 insertions, 2 deletions
diff --git a/xtask/src/cmd.rs b/xtask/src/cmd.rs
index 8e08a929b..37497fb74 100644
--- a/xtask/src/cmd.rs
+++ b/xtask/src/cmd.rs
@@ -37,6 +37,7 @@ pub fn run(cmdline: &str, dir: &str) -> Result<()> {
37pub fn run_with_output(cmdline: &str, dir: &str) -> Result<String> { 37pub fn run_with_output(cmdline: &str, dir: &str) -> Result<String> {
38 let output = do_run(cmdline, dir, &mut |_| {})?; 38 let output = do_run(cmdline, dir, &mut |_| {})?;
39 let stdout = String::from_utf8(output.stdout)?; 39 let stdout = String::from_utf8(output.stdout)?;
40 let stdout = stdout.trim().to_string();
40 Ok(stdout) 41 Ok(stdout)
41} 42}
42 43
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index 8fdf43e4a..1bb1882b0 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -15,7 +15,10 @@ use std::{
15 process::{Command, Stdio}, 15 process::{Command, Stdio},
16}; 16};
17 17
18use crate::{cmd::run, codegen::Mode}; 18use crate::{
19 cmd::{run, run_with_output},
20 codegen::Mode,
21};
19 22
20pub use anyhow::Result; 23pub use anyhow::Result;
21 24
@@ -156,3 +159,41 @@ fn rm_rf(path: &Path) -> Result<()> {
156 if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) } 159 if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) }
157 .with_context(|| format!("failed to remove {:?}", path)) 160 .with_context(|| format!("failed to remove {:?}", path))
158} 161}
162
163pub fn run_release() -> Result<()> {
164 run("git switch release", ".")?;
165 run("git fetch upstream", ".")?;
166 run("git reset --hard upstream/master", ".")?;
167 run("git push", ".")?;
168
169 let changelog_dir = project_root().join("../rust-analyzer.github.io/thisweek/_posts");
170
171 let today = run_with_output("date --iso", ".")?;
172 let commit = run_with_output("git rev-parse HEAD", ".")?;
173 let changelog_n = fs::read_dir(changelog_dir.as_path())?.count();
174
175 let contents = format!(
176 "\
177= Changelog #{}
178:sectanchors:
179:page-layout: post
180
181Commit: commit:{}[] +
182Release: release:{}[]
183
184== New Features
185
186* pr:[] .
187
188== Fixes
189
190== Internal Improvements
191",
192 changelog_n, commit, today
193 );
194
195 let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
196 fs::write(&path, &contents)?;
197
198 Ok(())
199}
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index c347de9ab..7ca727bde 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -14,7 +14,7 @@ use pico_args::Arguments;
14use xtask::{ 14use xtask::{
15 codegen::{self, Mode}, 15 codegen::{self, Mode},
16 install::{ClientOpt, InstallCmd, ServerOpt}, 16 install::{ClientOpt, InstallCmd, ServerOpt},
17 pre_commit, run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, 17 pre_commit, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, Result,
18}; 18};
19 19
20fn main() -> Result<()> { 20fn main() -> Result<()> {
@@ -92,6 +92,10 @@ FLAGS:
92 args.finish()?; 92 args.finish()?;
93 run_pre_cache() 93 run_pre_cache()
94 } 94 }
95 "release" => {
96 args.finish()?;
97 run_release()
98 }
95 _ => { 99 _ => {
96 eprintln!( 100 eprintln!(
97 "\ 101 "\