2021-02-12 17:52:51 +00:00
|
|
|
use std::fmt::Write;
|
|
|
|
|
2020-10-16 17:46:03 +00:00
|
|
|
use xshell::{cmd, cp, pushd, read_dir, write_file};
|
|
|
|
|
2021-03-08 18:13:15 +00:00
|
|
|
use crate::{codegen, date_iso, flags, is_release_tag, project_root, Result};
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2021-03-01 18:12:44 +00:00
|
|
|
impl flags::Release {
|
2021-03-01 17:16:23 +00:00
|
|
|
pub(crate) fn run(self) -> Result<()> {
|
2020-06-08 12:00:30 +00:00
|
|
|
if !self.dry_run {
|
2020-10-16 17:46:03 +00:00
|
|
|
cmd!("git switch release").run()?;
|
|
|
|
cmd!("git fetch upstream --tags --force").run()?;
|
|
|
|
cmd!("git reset --hard tags/nightly").run()?;
|
|
|
|
cmd!("git push").run()?;
|
2020-06-08 12:00:30 +00:00
|
|
|
}
|
2021-03-08 18:13:15 +00:00
|
|
|
codegen::docs()?;
|
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()?;
|
2020-10-16 17:46:03 +00:00
|
|
|
let commit = cmd!("git rev-parse HEAD").read()?;
|
|
|
|
let changelog_n = read_dir(changelog_dir.as_path())?.len();
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2021-02-12 17:52:51 +00:00
|
|
|
for &adoc in [
|
|
|
|
"manual.adoc",
|
|
|
|
"generated_assists.adoc",
|
|
|
|
"generated_config.adoc",
|
|
|
|
"generated_diagnostic.adoc",
|
|
|
|
"generated_features.adoc",
|
|
|
|
]
|
|
|
|
.iter()
|
|
|
|
{
|
|
|
|
let src = project_root().join("./docs/user/").join(adoc);
|
|
|
|
let dst = website_root.join(adoc);
|
|
|
|
cp(src, dst)?;
|
|
|
|
}
|
|
|
|
|
|
|
|
let tags = cmd!("git tag --list").read()?;
|
|
|
|
let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap();
|
|
|
|
|
|
|
|
let git_log = cmd!("git log {prev_tag}..HEAD --merges --reverse").read()?;
|
|
|
|
let mut git_log_summary = String::new();
|
|
|
|
for line in git_log.lines() {
|
|
|
|
let line = line.trim_start();
|
|
|
|
if let Some(p) = line.find(':') {
|
|
|
|
if let Ok(pr) = line[..p].parse::<u32>() {
|
|
|
|
writeln!(git_log_summary, "* pr:{}[]{}", pr, &line[p + 1..]).unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-09-14 13:56:30 +00:00
|
|
|
**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or
|
|
|
|
https://github.com/sponsors/rust-analyzer[GitHub Sponsors].
|
2020-07-06 15:13:08 +00:00
|
|
|
|
2020-06-22 13:11:22 +00:00
|
|
|
== New Features
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2021-02-12 17:52:51 +00:00
|
|
|
{}
|
2020-06-08 11:58:54 +00:00
|
|
|
|
2020-06-22 13:11:22 +00:00
|
|
|
== Fixes
|
|
|
|
|
|
|
|
== Internal Improvements
|
|
|
|
",
|
2021-02-12 17:52:51 +00:00
|
|
|
changelog_n, commit, today, git_log_summary
|
2020-06-08 12:00:30 +00:00
|
|
|
);
|
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));
|
2020-10-16 17:46:03 +00:00
|
|
|
write_file(&path, &contents)?;
|
2020-06-08 12:00:30 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2020-06-08 11:58:54 +00:00
|
|
|
}
|
2020-07-07 16:12:22 +00:00
|
|
|
|
2021-03-01 18:12:44 +00:00
|
|
|
impl flags::Promote {
|
2021-03-01 17:16:23 +00:00
|
|
|
pub(crate) fn run(self) -> Result<()> {
|
2020-10-16 17:46:03 +00:00
|
|
|
let _dir = pushd("../rust-rust-analyzer")?;
|
|
|
|
cmd!("git switch master").run()?;
|
|
|
|
cmd!("git fetch upstream").run()?;
|
|
|
|
cmd!("git reset --hard upstream/master").run()?;
|
|
|
|
cmd!("git submodule update --recursive").run()?;
|
2020-07-07 16:38:34 +00:00
|
|
|
|
|
|
|
let branch = format!("rust-analyzer-{}", date_iso()?);
|
2020-10-16 17:46:03 +00:00
|
|
|
cmd!("git switch -c {branch}").run()?;
|
2020-07-07 16:38:34 +00:00
|
|
|
{
|
2020-10-16 17:46:03 +00:00
|
|
|
let _dir = pushd("src/tools/rust-analyzer")?;
|
|
|
|
cmd!("git fetch origin").run()?;
|
|
|
|
cmd!("git reset --hard origin/release").run()?;
|
2020-07-07 16:38:34 +00:00
|
|
|
}
|
2020-10-16 17:46:03 +00:00
|
|
|
cmd!("git add src/tools/rust-analyzer").run()?;
|
|
|
|
cmd!("git commit -m':arrow_up: rust-analyzer'").run()?;
|
2020-07-07 16:38:34 +00:00
|
|
|
if !self.dry_run {
|
2021-02-08 14:20:42 +00:00
|
|
|
cmd!("git push -u").run()?;
|
2020-10-16 17:46:03 +00:00
|
|
|
cmd!("xdg-open https://github.com/matklad/rust/pull/new/{branch}?body=r%3F%20%40ghost")
|
|
|
|
.run()?;
|
2020-07-07 16:38:34 +00:00
|
|
|
}
|
2020-07-07 16:12:22 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|