aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/release.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/release.rs')
-rw-r--r--xtask/src/release.rs67
1 files changed, 67 insertions, 0 deletions
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 @@
1use crate::{
2 codegen, is_release_tag,
3 not_bash::{date_iso, fs2, run},
4 project_root, Mode, Result,
5};
6
7pub struct ReleaseCmd {
8 pub dry_run: bool,
9}
10
11impl 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}