vdev/commands/release/
github.rs1use crate::{app::CommandExt as _, utils::cargo};
2use anyhow::{Ok, Result, anyhow};
3use glob::glob;
4use std::process::Command;
5
6#[derive(clap::Args, Debug)]
8#[command()]
9pub struct Cli {}
10
11impl Cli {
12 pub fn exec(self) -> Result<()> {
13 let artifacts = glob("target/artifacts/*")
14 .expect("failed to read glob pattern")
15 .collect::<Result<Vec<_>, _>>()
16 .map_err(|e| anyhow!("failed to read path: {}", e))?
17 .into_iter()
18 .map(|p| p.into_os_string().into_string())
19 .collect::<Result<Vec<_>, _>>()
20 .map_err(|e| anyhow!("failed to turn path into string: {:?}", e))?;
21
22 let version = cargo::get_version()?;
23 let mut command = Command::new("gh");
24 command.in_repo();
25 command.args(
26 [
27 "release",
28 "--repo",
29 "vectordotdev/vector",
30 "create",
31 &format!("v{version}"),
32 "--title",
33 &format!("v{version}"),
34 "--notes",
35 &format!("[View release notes](https://vector.dev/releases/{version})"),
36 ]
37 .map(String::from)
38 .into_iter()
39 .chain(artifacts),
40 );
41 command.check_run()?;
42 Ok(())
43 }
44}