2021-03-29 00:55:43 -05:00
|
|
|
mod changelog;
|
2021-02-12 11:52:51 -06:00
|
|
|
|
2022-03-13 16:20:51 -05:00
|
|
|
use xshell::{cmd, Shell};
|
2020-10-16 12:46:03 -05:00
|
|
|
|
2022-03-13 16:20:51 -05:00
|
|
|
use crate::{date_iso, flags, is_release_tag, project_root};
|
2020-06-08 06:58:54 -05:00
|
|
|
|
2021-03-01 12:12:44 -06:00
|
|
|
impl flags::Release {
|
2022-03-13 16:20:51 -05:00
|
|
|
pub(crate) fn run(self, sh: &Shell) -> anyhow::Result<()> {
|
2020-06-08 07:00:30 -05:00
|
|
|
if !self.dry_run {
|
2022-03-13 16:20:51 -05:00
|
|
|
cmd!(sh, "git switch release").run()?;
|
|
|
|
cmd!(sh, "git fetch upstream --tags --force").run()?;
|
|
|
|
cmd!(sh, "git reset --hard tags/nightly").run()?;
|
2021-04-26 05:49:14 -05:00
|
|
|
// The `release` branch sometimes has a couple of cherry-picked
|
2021-04-26 05:41:34 -05:00
|
|
|
// commits for patch releases. If that's the case, just overwrite
|
|
|
|
// it. As we are setting `release` branch to an up-to-date `nightly`
|
|
|
|
// tag, this shouldn't be problematic in general.
|
|
|
|
//
|
2021-04-26 05:49:19 -05:00
|
|
|
// Note that, as we tag releases, we don't worry about "losing"
|
2021-04-26 05:41:34 -05:00
|
|
|
// commits -- they'll be kept alive by the tag. More generally, we
|
|
|
|
// don't care about historic releases all that much, it's fine even
|
|
|
|
// to delete old tags.
|
2022-03-13 16:20:51 -05:00
|
|
|
cmd!(sh, "git push --force").run()?;
|
2020-06-08 07:00:30 -05:00
|
|
|
}
|
2021-07-03 14:11:03 -05:00
|
|
|
|
|
|
|
// Generates bits of manual.adoc.
|
2022-05-02 03:41:06 -05:00
|
|
|
cmd!(sh, "cargo test -p ide-assists -p ide-diagnostics -p rust-analyzer -- sourcegen_")
|
2021-07-03 14:11:03 -05:00
|
|
|
.run()?;
|
2020-06-08 06:58:54 -05:00
|
|
|
|
2020-06-08 07:00:30 -05:00
|
|
|
let website_root = project_root().join("../rust-analyzer.github.io");
|
2021-11-22 07:45:47 -06:00
|
|
|
{
|
2022-03-13 16:20:51 -05:00
|
|
|
let _dir = sh.push_dir(&website_root);
|
|
|
|
cmd!(sh, "git switch src").run()?;
|
|
|
|
cmd!(sh, "git pull").run()?;
|
2021-11-22 07:45:47 -06:00
|
|
|
}
|
2020-06-08 07:00:30 -05:00
|
|
|
let changelog_dir = website_root.join("./thisweek/_posts");
|
2020-06-08 06:58:54 -05:00
|
|
|
|
2022-03-13 16:20:51 -05:00
|
|
|
let today = date_iso(sh)?;
|
|
|
|
let commit = cmd!(sh, "git rev-parse HEAD").read()?;
|
2022-06-18 09:00:28 -05:00
|
|
|
let changelog_n = sh
|
|
|
|
.read_dir(changelog_dir.as_path())?
|
|
|
|
.into_iter()
|
|
|
|
.filter_map(|p| p.file_stem().map(|s| s.to_string_lossy().to_string()))
|
|
|
|
.filter_map(|s| s.splitn(5, '-').last().map(|n| n.replace('-', ".")))
|
|
|
|
.filter_map(|s| s.parse::<f32>().ok())
|
|
|
|
.map(|n| 1 + n.floor() as usize)
|
|
|
|
.max()
|
|
|
|
.unwrap_or_default();
|
2020-06-08 06:58:54 -05:00
|
|
|
|
2021-10-03 07:45:08 -05:00
|
|
|
for adoc in [
|
2021-02-12 11:52:51 -06:00
|
|
|
"manual.adoc",
|
|
|
|
"generated_assists.adoc",
|
|
|
|
"generated_config.adoc",
|
|
|
|
"generated_diagnostic.adoc",
|
|
|
|
"generated_features.adoc",
|
2021-10-03 07:45:08 -05:00
|
|
|
] {
|
2021-02-12 11:52:51 -06:00
|
|
|
let src = project_root().join("./docs/user/").join(adoc);
|
|
|
|
let dst = website_root.join(adoc);
|
2021-05-07 16:19:01 -05:00
|
|
|
|
2022-03-13 16:20:51 -05:00
|
|
|
let contents = sh.read_file(src)?;
|
|
|
|
sh.write_file(dst, contents)?;
|
2021-02-12 11:52:51 -06:00
|
|
|
}
|
|
|
|
|
2022-03-13 16:20:51 -05:00
|
|
|
let tags = cmd!(sh, "git tag --list").read()?;
|
2021-02-12 11:52:51 -06:00
|
|
|
let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap();
|
|
|
|
|
2022-03-13 16:20:51 -05:00
|
|
|
let contents = changelog::get_changelog(sh, changelog_n, &commit, prev_tag, &today)?;
|
2022-12-23 12:42:58 -06:00
|
|
|
let path = changelog_dir.join(format!("{today}-changelog-{changelog_n}.adoc"));
|
2022-12-24 15:09:08 -06:00
|
|
|
sh.write_file(path, contents)?;
|
2020-06-08 07:00:30 -05:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2020-06-08 06:58:54 -05:00
|
|
|
}
|
2020-07-07 11:12:22 -05:00
|
|
|
|
2021-03-01 12:12:44 -06:00
|
|
|
impl flags::Promote {
|
2022-03-13 16:20:51 -05:00
|
|
|
pub(crate) fn run(self, sh: &Shell) -> anyhow::Result<()> {
|
|
|
|
let _dir = sh.push_dir("../rust-rust-analyzer");
|
|
|
|
cmd!(sh, "git switch master").run()?;
|
|
|
|
cmd!(sh, "git fetch upstream").run()?;
|
|
|
|
cmd!(sh, "git reset --hard upstream/master").run()?;
|
2020-07-07 11:38:34 -05:00
|
|
|
|
2022-03-13 16:20:51 -05:00
|
|
|
let date = date_iso(sh)?;
|
|
|
|
let branch = format!("rust-analyzer-{date}");
|
|
|
|
cmd!(sh, "git switch -c {branch}").run()?;
|
2022-08-03 01:48:44 -05:00
|
|
|
cmd!(sh, "git subtree pull -m ':arrow_up: rust-analyzer' -P src/tools/rust-analyzer rust-analyzer release").run()?;
|
2022-07-31 12:26:35 -05:00
|
|
|
|
2020-07-07 11:38:34 -05:00
|
|
|
if !self.dry_run {
|
2022-03-13 16:20:51 -05:00
|
|
|
cmd!(sh, "git push -u origin {branch}").run()?;
|
|
|
|
cmd!(
|
|
|
|
sh,
|
|
|
|
"xdg-open https://github.com/matklad/rust/pull/new/{branch}?body=r%3F%20%40ghost"
|
|
|
|
)
|
|
|
|
.run()?;
|
2020-07-07 11:38:34 -05:00
|
|
|
}
|
2020-07-07 11:12:22 -05:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|