diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/cmd.rs | 1 | ||||
-rw-r--r-- | xtask/src/lib.rs | 43 | ||||
-rw-r--r-- | xtask/src/main.rs | 6 |
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<()> { | |||
37 | pub fn run_with_output(cmdline: &str, dir: &str) -> Result<String> { | 37 | pub 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 | ||
18 | use crate::{cmd::run, codegen::Mode}; | 18 | use crate::{ |
19 | cmd::{run, run_with_output}, | ||
20 | codegen::Mode, | ||
21 | }; | ||
19 | 22 | ||
20 | pub use anyhow::Result; | 23 | pub 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 | |||
163 | pub 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 | |||
181 | Commit: commit:{}[] + | ||
182 | Release: 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; | |||
14 | use xtask::{ | 14 | use 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 | ||
20 | fn main() -> Result<()> { | 20 | fn 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 | "\ |