Skip to content

Commit 7d112b9

Browse files
committed
build(dev): force use versions.json in docs.rs build
for clang-tools-manager crate's build script actually publish clang-tools-manager dirty; forgot to use the env var in CI `run` field. ref #365
1 parent 8f49650 commit 7d112b9

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

.github/workflows/binary-builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,4 @@ jobs:
228228
# but docs.rs build requires the versions.json file present to
229229
# avoid clang-tools-manager/build.rs using network access.
230230
PUB_ARG: ${{ startsWith(github.ref_name, 'clang-tools-manager/v') && '--allow-dirty' || '' }}
231-
run: cargo publish -p ${PKG_NAME}
231+
run: cargo publish -p ${PKG_NAME} ${PUB_ARG}

clang-tools-manager/build.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ fn main() {
1818
let pre_seed = PathBuf::from("versions.json");
1919
let version_info_str = if pre_seed.exists()
2020
&& let Ok(metadata) = fs::metadata(&pre_seed)
21-
&& metadata.modified().is_ok_and(|d| {
22-
SystemTime::now()
23-
.duration_since(d)
24-
// repopulate cached file in case of error
25-
.unwrap_or(Duration::from_hours(25))
26-
< Duration::from_hours(24)
27-
}) {
21+
// if this is a docs.rs build, then use the versions,json present in the package.
22+
&& (std::env::var_os("DOCS_RS").is_some()
23+
// otherwise, check if the file is not too old (24 hours)
24+
|| metadata.modified().is_ok_and(|d| {
25+
SystemTime::now()
26+
.duration_since(d)
27+
// repopulate cached file in case of error
28+
.unwrap_or(Duration::from_hours(25))
29+
< Duration::from_hours(24)
30+
})) {
2831
println!("cargo:warning=Using pre-seeded version info from {pre_seed:?}");
2932
fs::read_to_string(&pre_seed).unwrap()
3033
} else {

0 commit comments

Comments
 (0)