diff --git a/src/commands/publish.rs b/src/commands/publish.rs index cdae6ef940b1a7884dd0bccdc4e51ea34ac1e891..c68aa167aac318b5338c9c1d5b4d585999cf905a 100644 --- a/src/commands/publish.rs +++ b/src/commands/publish.rs @@ -11,6 +11,12 @@ pub async fn handle_command() -> Result<(), GcliError> { // Step 1: Get actual version of gcli const VERSION: &str = env!("CARGO_PKG_VERSION"); + // Fetch the latest tags from the remote repository + Command::new("git") + .args(["fetch", "--tags"]) + .status() + .map_err(|e| anyhow!(e))?; + // Step 2: Check if the git tag already exists let tag_check_output = Command::new("git").args(["tag", "-l", VERSION]).output()?; @@ -28,6 +34,7 @@ pub async fn handle_command() -> Result<(), GcliError> { Ok(true) => { // User confirmed, proceed publishing // Step 3: Create and push the git tag + Command::new("git") .args(["tag", "-a", VERSION, "-m", &format!("Release v{VERSION}")]) .status()