Skip to content

Commit 10ead7e

Browse files
committed
ci: Make sure to fetch git tags
1 parent aaea06d commit 10ead7e

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
steps:
2424
- name: Checkout source code
2525
uses: actions/checkout@v4
26+
- name: Get tags
27+
run: git fetch --tags origin
2628
- name: Configure build cache
2729
uses: actions/cache@v4
2830
with:
@@ -59,6 +61,8 @@ jobs:
5961
- x86_64-apple-darwin
6062
steps:
6163
- uses: actions/checkout@v4
64+
- name: Get tags
65+
run: git fetch --tags origin
6266
- name: Configure build cache
6367
uses: actions/cache@v4
6468
with:

build.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,24 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
5050
// If `HEAD` doesn't have a tag pointing to it, this is a development version,
5151
// so find the closest tag starting with `v` and append `-dev` to the version.
5252
// Eg. "1.0.43-dev".
53-
Command::new("git")
53+
let output = Command::new("git")
5454
.arg("describe")
5555
.arg("--match=v*") // Match tags starting with `v`
5656
.arg("--candidates=1") // Only one result
5757
.arg("--abbrev=0") // Don't add the commit short-hash to the tag name
5858
.arg("HEAD")
59-
.output()
60-
.ok()
61-
.and_then(|output| {
62-
if output.status.success() {
63-
String::from_utf8(output.stdout).ok()
64-
} else {
65-
None
66-
}
67-
})
68-
.map(|last| format!("{}-dev", last.trim()))
59+
.output()?;
60+
if output.status.success() {
61+
String::from_utf8(output.stdout)
62+
.ok()
63+
.map(|last| format!("{}-dev", last.trim()))
64+
} else {
65+
println!(
66+
"cargo::warn=error:{}",
67+
String::from_utf8_lossy(&output.stderr)
68+
);
69+
None
70+
}
6971
}
7072
// If there are no tags found, we'll just call this a pre-release.
7173
.unwrap_or(String::from("pre-release"));

0 commit comments

Comments
 (0)