aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-08 12:58:54 +0100
committerAleksey Kladov <[email protected]>2020-06-08 12:58:54 +0100
commit97ea2dfc4b6b49a175d4d0f85b37c77bd1ea3f3b (patch)
tree862095016a179751c2f6f7070935f259a441a22c /xtask
parent6e4fca5882bdd6d00dfcc384473c1f612e00baa2 (diff)
Move to a dedicated file
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/lib.rs57
-rw-r--r--xtask/src/main.rs5
-rw-r--r--xtask/src/release.rs59
3 files changed, 64 insertions, 57 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index 739f49f7b..747654c1f 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -4,6 +4,7 @@
4 4
5pub mod not_bash; 5pub mod not_bash;
6pub mod install; 6pub mod install;
7pub mod release;
7pub mod dist; 8pub mod dist;
8pub mod pre_commit; 9pub mod pre_commit;
9 10
@@ -19,7 +20,7 @@ use walkdir::{DirEntry, WalkDir};
19 20
20use crate::{ 21use crate::{
21 codegen::Mode, 22 codegen::Mode,
22 not_bash::{date_iso, fs2, pushd, pushenv, rm_rf, run}, 23 not_bash::{fs2, pushd, pushenv, rm_rf, run},
23}; 24};
24 25
25pub use anyhow::{bail, Context as _, Result}; 26pub use anyhow::{bail, Context as _, Result};
@@ -153,60 +154,6 @@ pub fn run_pre_cache() -> Result<()> {
153 Ok(()) 154 Ok(())
154} 155}
155 156
156pub fn run_release(dry_run: bool) -> Result<()> {
157 if !dry_run {
158 run!("git switch release")?;
159 run!("git fetch upstream --tags --force")?;
160 run!("git reset --hard tags/nightly")?;
161 run!("git push")?;
162 }
163 codegen::generate_assists_docs(Mode::Overwrite)?;
164 codegen::generate_feature_docs(Mode::Overwrite)?;
165
166 let website_root = project_root().join("../rust-analyzer.github.io");
167 let changelog_dir = website_root.join("./thisweek/_posts");
168
169 let today = date_iso()?;
170 let commit = run!("git rev-parse HEAD")?;
171 let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count();
172
173 let contents = format!(
174 "\
175= Changelog #{}
176:sectanchors:
177:page-layout: post
178
179Commit: commit:{}[] +
180Release: release:{}[]
181
182== New Features
183
184* pr:[] .
185
186== Fixes
187
188== Internal Improvements
189",
190 changelog_n, commit, today
191 );
192
193 let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
194 fs2::write(&path, &contents)?;
195
196 for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() {
197 let src = project_root().join("./docs/user/").join(adoc);
198 let dst = website_root.join(adoc);
199 fs2::copy(src, dst)?;
200 }
201
202 let tags = run!("git tag --list"; echo = false)?;
203 let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap();
204
205 println!("\n git log {}..HEAD --merges --reverse", prev_tag);
206
207 Ok(())
208}
209
210fn is_release_tag(tag: &str) -> bool { 157fn is_release_tag(tag: &str) -> bool {
211 tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) 158 tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit())
212} 159}
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index 81bb3a33f..701c60fc0 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -16,8 +16,9 @@ use xtask::{
16 dist::run_dist, 16 dist::run_dist,
17 install::{ClientOpt, InstallCmd, ServerOpt}, 17 install::{ClientOpt, InstallCmd, ServerOpt},
18 not_bash::pushd, 18 not_bash::pushd,
19 pre_commit, project_root, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, 19 pre_commit, project_root,
20 Result, 20 release::run_release,
21 run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result,
21}; 22};
22 23
23fn main() -> Result<()> { 24fn main() -> Result<()> {
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
new file mode 100644
index 000000000..771a8cf71
--- /dev/null
+++ b/xtask/src/release.rs
@@ -0,0 +1,59 @@
1use crate::{
2 codegen, is_release_tag,
3 not_bash::{date_iso, fs2, run},
4 project_root, Mode, Result,
5};
6
7pub fn run_release(dry_run: bool) -> Result<()> {
8 if !dry_run {
9 run!("git switch release")?;
10 run!("git fetch upstream --tags --force")?;
11 run!("git reset --hard tags/nightly")?;
12 run!("git push")?;
13 }
14 codegen::generate_assists_docs(Mode::Overwrite)?;
15 codegen::generate_feature_docs(Mode::Overwrite)?;
16
17 let website_root = project_root().join("../rust-analyzer.github.io");
18 let changelog_dir = website_root.join("./thisweek/_posts");
19
20 let today = date_iso()?;
21 let commit = run!("git rev-parse HEAD")?;
22 let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count();
23
24 let contents = format!(
25 "\
26= Changelog #{}
27:sectanchors:
28:page-layout: post
29
30Commit: commit:{}[] +
31Release: release:{}[]
32
33== New Features
34
35* pr:[] .
36
37== Fixes
38
39== Internal Improvements
40",
41 changelog_n, commit, today
42 );
43
44 let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
45 fs2::write(&path, &contents)?;
46
47 for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() {
48 let src = project_root().join("./docs/user/").join(adoc);
49 let dst = website_root.join(adoc);
50 fs2::copy(src, dst)?;
51 }
52
53 let tags = run!("git tag --list"; echo = false)?;
54 let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap();
55
56 println!("\n git log {}..HEAD --merges --reverse", prev_tag);
57
58 Ok(())
59}