aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/release.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-17 01:44:12 +0100
committerGitHub <[email protected]>2020-10-17 01:44:12 +0100
commit59483c217662fc5d89ef9da1cb93760e14a48418 (patch)
treecf93fa6a4f3d18e8be27acf56ee85927fd6f66c7 /xtask/src/release.rs
parentf0412da4a2c06e50030d13e37002d0440fc7cded (diff)
parent49a90d4c31148a6533d9ee9a288f42b454b2f421 (diff)
Merge #6260
6260: xshell r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'xtask/src/release.rs')
-rw-r--r--xtask/src/release.rs60
1 files changed, 28 insertions, 32 deletions
diff --git a/xtask/src/release.rs b/xtask/src/release.rs
index 3aab29801..14fc1f0dd 100644
--- a/xtask/src/release.rs
+++ b/xtask/src/release.rs
@@ -1,8 +1,6 @@
1use crate::{ 1use xshell::{cmd, cp, pushd, read_dir, write_file};
2 codegen, is_release_tag, 2
3 not_bash::{date_iso, fs2, pushd, run}, 3use crate::{codegen, date_iso, is_release_tag, project_root, Mode, Result};
4 project_root, Mode, Result,
5};
6 4
7pub struct ReleaseCmd { 5pub struct ReleaseCmd {
8 pub dry_run: bool, 6 pub dry_run: bool,
@@ -11,10 +9,10 @@ pub struct ReleaseCmd {
11impl ReleaseCmd { 9impl ReleaseCmd {
12 pub fn run(self) -> Result<()> { 10 pub fn run(self) -> Result<()> {
13 if !self.dry_run { 11 if !self.dry_run {
14 run!("git switch release")?; 12 cmd!("git switch release").run()?;
15 run!("git fetch upstream --tags --force")?; 13 cmd!("git fetch upstream --tags --force").run()?;
16 run!("git reset --hard tags/nightly")?; 14 cmd!("git reset --hard tags/nightly").run()?;
17 run!("git push")?; 15 cmd!("git push").run()?;
18 } 16 }
19 codegen::generate_assists_docs(Mode::Overwrite)?; 17 codegen::generate_assists_docs(Mode::Overwrite)?;
20 codegen::generate_feature_docs(Mode::Overwrite)?; 18 codegen::generate_feature_docs(Mode::Overwrite)?;
@@ -23,8 +21,8 @@ impl ReleaseCmd {
23 let changelog_dir = website_root.join("./thisweek/_posts"); 21 let changelog_dir = website_root.join("./thisweek/_posts");
24 22
25 let today = date_iso()?; 23 let today = date_iso()?;
26 let commit = run!("git rev-parse HEAD")?; 24 let commit = cmd!("git rev-parse HEAD").read()?;
27 let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); 25 let changelog_n = read_dir(changelog_dir.as_path())?.len();
28 26
29 let contents = format!( 27 let contents = format!(
30 "\ 28 "\
@@ -52,20 +50,20 @@ https://github.com/sponsors/rust-analyzer[GitHub Sponsors].
52 ); 50 );
53 51
54 let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); 52 let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
55 fs2::write(&path, &contents)?; 53 write_file(&path, &contents)?;
56 54
57 for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { 55 for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() {
58 let src = project_root().join("./docs/user/").join(adoc); 56 let src = project_root().join("./docs/user/").join(adoc);
59 let dst = website_root.join(adoc); 57 let dst = website_root.join(adoc);
60 fs2::copy(src, dst)?; 58 cp(src, dst)?;
61 } 59 }
62 60
63 let tags = run!("git tag --list"; echo = false)?; 61 let tags = cmd!("git tag --list").read()?;
64 let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); 62 let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap();
65 63
66 let git_log = run!("git log {}..HEAD --merges --reverse", prev_tag; echo = false)?; 64 let git_log = cmd!("git log {prev_tag}..HEAD --merges --reverse").read()?;
67 let git_log_dst = website_root.join("git.log"); 65 let git_log_dst = website_root.join("git.log");
68 fs2::write(git_log_dst, &git_log)?; 66 write_file(git_log_dst, &git_log)?;
69 67
70 Ok(()) 68 Ok(())
71 } 69 }
@@ -77,27 +75,25 @@ pub struct PromoteCmd {
77 75
78impl PromoteCmd { 76impl PromoteCmd {
79 pub fn run(self) -> Result<()> { 77 pub fn run(self) -> Result<()> {
80 let _dir = pushd("../rust-rust-analyzer"); 78 let _dir = pushd("../rust-rust-analyzer")?;
81 run!("git switch master")?; 79 cmd!("git switch master").run()?;
82 run!("git fetch upstream")?; 80 cmd!("git fetch upstream").run()?;
83 run!("git reset --hard upstream/master")?; 81 cmd!("git reset --hard upstream/master").run()?;
84 run!("git submodule update --recursive")?; 82 cmd!("git submodule update --recursive").run()?;
85 83
86 let branch = format!("rust-analyzer-{}", date_iso()?); 84 let branch = format!("rust-analyzer-{}", date_iso()?);
87 run!("git switch -c {}", branch)?; 85 cmd!("git switch -c {branch}").run()?;
88 { 86 {
89 let _dir = pushd("src/tools/rust-analyzer"); 87 let _dir = pushd("src/tools/rust-analyzer")?;
90 run!("git fetch origin")?; 88 cmd!("git fetch origin").run()?;
91 run!("git reset --hard origin/release")?; 89 cmd!("git reset --hard origin/release").run()?;
92 } 90 }
93 run!("git add src/tools/rust-analyzer")?; 91 cmd!("git add src/tools/rust-analyzer").run()?;
94 run!("git commit -m':arrow_up: rust-analyzer'")?; 92 cmd!("git commit -m':arrow_up: rust-analyzer'").run()?;
95 if !self.dry_run { 93 if !self.dry_run {
96 run!("git push")?; 94 cmd!("git push").run()?;
97 run!( 95 cmd!("xdg-open https://github.com/matklad/rust/pull/new/{branch}?body=r%3F%20%40ghost")
98 "xdg-open https://github.com/matklad/rust/pull/new/{}?body=r%3F%20%40ghost", 96 .run()?;
99 branch
100 )?;
101 } 97 }
102 Ok(()) 98 Ok(())
103 } 99 }