summaryrefslogtreecommitdiff
path: root/src/git.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-03-28 13:19:02 +0300
committerLars Wirzenius <liw@liw.fi>2021-03-28 16:26:45 +0300
commitc444c915fc349ee345080aa4d151f9416b5c0ab8 (patch)
treeea41a40f3e29db50758d1f9d3744b7b78702743b /src/git.rs
parent81fa9799b1393f427e4095978285cabbaa809735 (diff)
downloadbumper-rs-c444c915fc349ee345080aa4d151f9416b5c0ab8.tar.gz
feat: create git tag for release
Diffstat (limited to 'src/git.rs')
-rw-r--r--src/git.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/git.rs b/src/git.rs
new file mode 100644
index 0000000..76f6da1
--- /dev/null
+++ b/src/git.rs
@@ -0,0 +1,25 @@
+use crate::errors::BumperError;
+use log::{debug, info};
+use std::process::Command;
+
+pub fn tag(version: &str) -> Result<(), BumperError> {
+ let tag_name = format!("v{}", version);
+ info!("Create git tag {}", tag_name);
+ let output = Command::new("git")
+ .arg("tag")
+ .arg("-am")
+ .arg(format!("release version {}", version))
+ .arg(format!("v{}", version))
+ .output();
+ let output = match output {
+ Ok(output) => output,
+ Err(err) => {
+ return Err(BumperError::GitInvoke(err));
+ }
+ };
+ debug!("git exit code was {:?}", output.status.code());
+ if !output.status.success() {
+ return Err(BumperError::git_tag(&output.stderr));
+ }
+ Ok(())
+}