From 97ea2dfc4b6b49a175d4d0f85b37c77bd1ea3f3b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 8 Jun 2020 13:58:54 +0200 Subject: Move to a dedicated file --- xtask/src/lib.rs | 57 ++------------------------------------------------ xtask/src/main.rs | 5 +++-- xtask/src/release.rs | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 57 deletions(-) create mode 100644 xtask/src/release.rs (limited to 'xtask') 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 @@ pub mod not_bash; pub mod install; +pub mod release; pub mod dist; pub mod pre_commit; @@ -19,7 +20,7 @@ use walkdir::{DirEntry, WalkDir}; use crate::{ codegen::Mode, - not_bash::{date_iso, fs2, pushd, pushenv, rm_rf, run}, + not_bash::{fs2, pushd, pushenv, rm_rf, run}, }; pub use anyhow::{bail, Context as _, Result}; @@ -153,60 +154,6 @@ pub fn run_pre_cache() -> Result<()> { Ok(()) } -pub fn run_release(dry_run: bool) -> Result<()> { - if !dry_run { - run!("git switch release")?; - run!("git fetch upstream --tags --force")?; - run!("git reset --hard tags/nightly")?; - run!("git push")?; - } - codegen::generate_assists_docs(Mode::Overwrite)?; - codegen::generate_feature_docs(Mode::Overwrite)?; - - let website_root = project_root().join("../rust-analyzer.github.io"); - let changelog_dir = website_root.join("./thisweek/_posts"); - - let today = date_iso()?; - let commit = run!("git rev-parse HEAD")?; - let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); - - let contents = format!( - "\ -= Changelog #{} -:sectanchors: -:page-layout: post - -Commit: commit:{}[] + -Release: release:{}[] - -== New Features - -* pr:[] . - -== Fixes - -== Internal Improvements -", - changelog_n, commit, today - ); - - let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); - fs2::write(&path, &contents)?; - - for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { - let src = project_root().join("./docs/user/").join(adoc); - let dst = website_root.join(adoc); - fs2::copy(src, dst)?; - } - - let tags = run!("git tag --list"; echo = false)?; - let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); - - println!("\n git log {}..HEAD --merges --reverse", prev_tag); - - Ok(()) -} - fn is_release_tag(tag: &str) -> bool { tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit()) } 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::{ dist::run_dist, install::{ClientOpt, InstallCmd, ServerOpt}, not_bash::pushd, - pre_commit, project_root, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, - Result, + pre_commit, project_root, + release::run_release, + run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result, }; fn 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 @@ +use crate::{ + codegen, is_release_tag, + not_bash::{date_iso, fs2, run}, + project_root, Mode, Result, +}; + +pub fn run_release(dry_run: bool) -> Result<()> { + if !dry_run { + run!("git switch release")?; + run!("git fetch upstream --tags --force")?; + run!("git reset --hard tags/nightly")?; + run!("git push")?; + } + codegen::generate_assists_docs(Mode::Overwrite)?; + codegen::generate_feature_docs(Mode::Overwrite)?; + + let website_root = project_root().join("../rust-analyzer.github.io"); + let changelog_dir = website_root.join("./thisweek/_posts"); + + let today = date_iso()?; + let commit = run!("git rev-parse HEAD")?; + let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count(); + + let contents = format!( + "\ += Changelog #{} +:sectanchors: +:page-layout: post + +Commit: commit:{}[] + +Release: release:{}[] + +== New Features + +* pr:[] . + +== Fixes + +== Internal Improvements +", + changelog_n, commit, today + ); + + let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); + fs2::write(&path, &contents)?; + + for &adoc in ["manual.adoc", "generated_features.adoc", "generated_assists.adoc"].iter() { + let src = project_root().join("./docs/user/").join(adoc); + let dst = website_root.join(adoc); + fs2::copy(src, dst)?; + } + + let tags = run!("git tag --list"; echo = false)?; + let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); + + println!("\n git log {}..HEAD --merges --reverse", prev_tag); + + Ok(()) +} -- cgit v1.2.3