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