diff options
-rw-r--r-- | xtask/src/lib.rs | 57 | ||||
-rw-r--r-- | xtask/src/main.rs | 7 | ||||
-rw-r--r-- | xtask/src/release.rs | 67 |
3 files changed, 73 insertions, 58 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 | ||
5 | pub mod not_bash; | 5 | pub mod not_bash; |
6 | pub mod install; | 6 | pub mod install; |
7 | pub mod release; | ||
7 | pub mod dist; | 8 | pub mod dist; |
8 | pub mod pre_commit; | 9 | pub mod pre_commit; |
9 | 10 | ||
@@ -19,7 +20,7 @@ use walkdir::{DirEntry, WalkDir}; | |||
19 | 20 | ||
20 | use crate::{ | 21 | use 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 | ||
25 | pub use anyhow::{bail, Context as _, Result}; | 26 | pub use anyhow::{bail, Context as _, Result}; |
@@ -153,60 +154,6 @@ pub fn run_pre_cache() -> Result<()> { | |||
153 | Ok(()) | 154 | Ok(()) |
154 | } | 155 | } |
155 | 156 | ||
156 | pub 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 | |||
179 | Commit: commit:{}[] + | ||
180 | Release: 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 | |||
210 | fn is_release_tag(tag: &str) -> bool { | 157 | fn 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..f7a79362d 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::ReleaseCmd, |
21 | run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, | ||
21 | }; | 22 | }; |
22 | 23 | ||
23 | fn main() -> Result<()> { | 24 | fn main() -> Result<()> { |
@@ -102,7 +103,7 @@ FLAGS: | |||
102 | "release" => { | 103 | "release" => { |
103 | let dry_run = args.contains("--dry-run"); | 104 | let dry_run = args.contains("--dry-run"); |
104 | args.finish()?; | 105 | args.finish()?; |
105 | run_release(dry_run) | 106 | ReleaseCmd { dry_run }.run() |
106 | } | 107 | } |
107 | "dist" => { | 108 | "dist" => { |
108 | let nightly = args.contains("--nightly"); | 109 | let nightly = args.contains("--nightly"); |
diff --git a/xtask/src/release.rs b/xtask/src/release.rs new file mode 100644 index 000000000..36c912184 --- /dev/null +++ b/xtask/src/release.rs | |||
@@ -0,0 +1,67 @@ | |||
1 | use crate::{ | ||
2 | codegen, is_release_tag, | ||
3 | not_bash::{date_iso, fs2, run}, | ||
4 | project_root, Mode, Result, | ||
5 | }; | ||
6 | |||
7 | pub struct ReleaseCmd { | ||
8 | pub dry_run: bool, | ||
9 | } | ||
10 | |||
11 | impl ReleaseCmd { | ||
12 | pub fn run(self) -> Result<()> { | ||
13 | if !self.dry_run { | ||
14 | run!("git switch release")?; | ||
15 | run!("git fetch upstream --tags --force")?; | ||
16 | run!("git reset --hard tags/nightly")?; | ||
17 | run!("git push")?; | ||
18 | } | ||
19 | codegen::generate_assists_docs(Mode::Overwrite)?; | ||
20 | codegen::generate_feature_docs(Mode::Overwrite)?; | ||
21 | |||
22 | let website_root = project_root().join("../rust-analyzer.github.io"); | ||
23 | let changelog_dir = website_root.join("./thisweek/_posts"); | ||
24 | |||
25 | let today = date_iso()?; | ||
26 | let commit = run!("git rev-parse HEAD")?; | ||
27 | let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); | ||
28 | |||
29 | let contents = format!( | ||
30 | "\ | ||
31 | = Changelog #{} | ||
32 | :sectanchors: | ||
33 | :page-layout: post | ||
34 | |||
35 | Commit: commit:{}[] + | ||
36 | Release: release:{}[] | ||
37 | |||
38 | == New Features | ||
39 | |||
40 | * pr:[] . | ||
41 | |||
42 | == Fixes | ||
43 | |||
44 | == Internal Improvements | ||
45 | ", | ||
46 | changelog_n, commit, today | ||
47 | ); | ||
48 | |||
49 | let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); | ||
50 | fs2::write(&path, &contents)?; | ||
51 | |||
52 | for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { | ||
53 | let src = project_root().join("./docs/user/").join(adoc); | ||
54 | let dst = website_root.join(adoc); | ||
55 | fs2::copy(src, dst)?; | ||
56 | } | ||
57 | |||
58 | let tags = run!("git tag --list"; echo = false)?; | ||
59 | let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); | ||
60 | |||
61 | let git_log = run!("git log {}..HEAD --merges --reverse", prev_tag; echo = false)?; | ||
62 | let git_log_dst = website_root.join("git.log"); | ||
63 | fs2::write(git_log_dst, &git_log)?; | ||
64 | |||
65 | Ok(()) | ||
66 | } | ||
67 | } | ||