2020-06-08 11:58:54 +00:00
|
|
|
use crate::{
|
|
|
|
codegen, is_release_tag,
|
|
|
|
not_bash::{date_iso, fs2, run},
|
|
|
|
project_root, Mode, Result,
|
|
|
|
};
|
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
pub struct ReleaseCmd {
|
|
|
|
pub dry_run: bool,
|
|
|
|
}
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
impl ReleaseCmd {
|
|
|
|
pub fn run(self) -> Result<()> {
|
|
|
|
if !self.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)?;
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
let website_root = project_root().join("../rust-analyzer.github.io");
|
|
|
|
let changelog_dir = website_root.join("./thisweek/_posts");
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
let today = date_iso()?;
|
|
|
|
let commit = run!("git rev-parse HEAD")?;
|
|
|
|
let changelog_n = fs2::read_dir(changelog_dir.as_path())?.count();
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
let contents = format!(
|
|
|
|
"\
|
2020-06-22 13:11:22 +00:00
|
|
|
= Changelog #{}
|
|
|
|
:sectanchors:
|
|
|
|
:page-layout: post
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-22 13:11:22 +00:00
|
|
|
Commit: commit:{}[] +
|
|
|
|
Release: release:{}[]
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-22 13:11:22 +00:00
|
|
|
== Sponsors
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-22 13:11:22 +00:00
|
|
|
== New Features
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-22 13:11:22 +00:00
|
|
|
* pr:[] .
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-22 13:11:22 +00:00
|
|
|
== Fixes
|
|
|
|
|
|
|
|
== Internal Improvements
|
|
|
|
",
|
2020-06-08 12:00:30 +00:00
|
|
|
changelog_n, commit, today
|
|
|
|
);
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n));
|
|
|
|
fs2::write(&path, &contents)?;
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
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)?;
|
|
|
|
}
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
let tags = run!("git tag --list"; echo = false)?;
|
|
|
|
let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap();
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-08 12:00:30 +00:00
|
|
|
let git_log = run!("git log {}..HEAD --merges --reverse", prev_tag; echo = false)?;
|
|
|
|
let git_log_dst = website_root.join("git.log");
|
|
|
|
fs2::write(git_log_dst, &git_log)?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2020-06-08 11:58:54 +00:00
|
|
|
}
|