mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
xtask release
This commit is contained in:
parent
1b6acc391a
commit
57147d7471
3 changed files with 48 additions and 2 deletions
|
@ -37,6 +37,7 @@ pub fn run(cmdline: &str, dir: &str) -> Result<()> {
|
|||
pub fn run_with_output(cmdline: &str, dir: &str) -> Result<String> {
|
||||
let output = do_run(cmdline, dir, &mut |_| {})?;
|
||||
let stdout = String::from_utf8(output.stdout)?;
|
||||
let stdout = stdout.trim().to_string();
|
||||
Ok(stdout)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ use std::{
|
|||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
use crate::{cmd::run, codegen::Mode};
|
||||
use crate::{
|
||||
cmd::{run, run_with_output},
|
||||
codegen::Mode,
|
||||
};
|
||||
|
||||
pub use anyhow::Result;
|
||||
|
||||
|
@ -156,3 +159,41 @@ fn rm_rf(path: &Path) -> Result<()> {
|
|||
if path.is_file() { fs::remove_file(path) } else { fs::remove_dir_all(path) }
|
||||
.with_context(|| format!("failed to remove {:?}", path))
|
||||
}
|
||||
|
||||
pub fn run_release() -> Result<()> {
|
||||
run("git switch release", ".")?;
|
||||
run("git fetch upstream", ".")?;
|
||||
run("git reset --hard upstream/master", ".")?;
|
||||
run("git push", ".")?;
|
||||
|
||||
let changelog_dir = project_root().join("../rust-analyzer.github.io/thisweek/_posts");
|
||||
|
||||
let today = run_with_output("date --iso", ".")?;
|
||||
let commit = run_with_output("git rev-parse HEAD", ".")?;
|
||||
let changelog_n = fs::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));
|
||||
fs::write(&path, &contents)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use pico_args::Arguments;
|
|||
use xtask::{
|
||||
codegen::{self, Mode},
|
||||
install::{ClientOpt, InstallCmd, ServerOpt},
|
||||
pre_commit, run_clippy, run_fuzzer, run_pre_cache, run_rustfmt, Result,
|
||||
pre_commit, run_clippy, run_fuzzer, run_pre_cache, run_release, run_rustfmt, Result,
|
||||
};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
|
@ -92,6 +92,10 @@ FLAGS:
|
|||
args.finish()?;
|
||||
run_pre_cache()
|
||||
}
|
||||
"release" => {
|
||||
args.finish()?;
|
||||
run_release()
|
||||
}
|
||||
_ => {
|
||||
eprintln!(
|
||||
"\
|
||||
|
|
Loading…
Reference in a new issue