diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 141e94972..94a24dff1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v4 + - name: Get tags + run: git fetch --tags origin - name: Configure build cache uses: actions/cache@v4 with: @@ -59,6 +61,8 @@ jobs: - x86_64-apple-darwin steps: - uses: actions/checkout@v4 + - name: Get tags + run: git fetch --tags origin - name: Configure build cache uses: actions/cache@v4 with: diff --git a/build.rs b/build.rs index 620232c60..ba64e99df 100644 --- a/build.rs +++ b/build.rs @@ -50,22 +50,24 @@ fn main() -> Result<(), Box> { // If `HEAD` doesn't have a tag pointing to it, this is a development version, // so find the closest tag starting with `v` and append `-dev` to the version. // Eg. "1.0.43-dev". - Command::new("git") + let output = Command::new("git") .arg("describe") .arg("--match=v*") // Match tags starting with `v` .arg("--candidates=1") // Only one result .arg("--abbrev=0") // Don't add the commit short-hash to the tag name .arg("HEAD") - .output() - .ok() - .and_then(|output| { - if output.status.success() { - String::from_utf8(output.stdout).ok() - } else { - None - } - }) - .map(|last| format!("{}-dev", last.trim())) + .output()?; + if output.status.success() { + String::from_utf8(output.stdout) + .ok() + .map(|last| format!("{}-dev", last.trim())) + } else { + println!( + "cargo::warn=error:{}", + String::from_utf8_lossy(&output.stderr) + ); + None + } } // If there are no tags found, we'll just call this a pre-release. .unwrap_or(String::from("pre-release"));