vdev/commands/release/
push.rs

1use anyhow::Result;
2use clap::Args;
3
4use crate::{app, utils::git};
5use itertools::Itertools;
6
7/// Pushes new versions produced by `make release` to the repository
8#[derive(Args, Debug)]
9#[command()]
10pub struct Cli {}
11
12impl Cli {
13    pub fn exec(self) -> Result<()> {
14        let version = app::version()?;
15        let version_minor = version.split('.').take(2).join(".");
16
17        let current_branch = git::current_branch()?;
18        let branch_name = format!("v{version_minor}");
19        let tag_name = format!("v{version}");
20        println!("Preparing the branch and the tag...");
21        git::checkout_or_create_branch(&branch_name)?;
22        git::merge_branch(&current_branch)?;
23        git::tag_version(&tag_name)?;
24
25        println!("Pushing the branch and the tag...");
26        git::push_branch(&branch_name)?;
27        git::push_branch(&tag_name)?;
28
29        Ok(())
30    }
31}