From 8ac344ac72655c203e18a26c009ef5feeac7a994 Mon Sep 17 00:00:00 2001 From: poka <poka@p2p.legal> Date: Fri, 2 Feb 2024 19:15:15 +0100 Subject: [PATCH] enh: fetch local tags before check if release already exist --- src/commands/publish.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/commands/publish.rs b/src/commands/publish.rs index cdae6ef..c68aa16 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() -- GitLab