Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/binary-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
publish:
if: startswith(github.ref, 'refs/tags/cpp-linter/v') || startswith(github.ref, 'refs/tags/clang-tools-manager/v')
runs-on: ubuntu-latest
needs: [create-assets]
needs: [create-assets, seed-build-script]
permissions:
id-token: write
contents: write
Expand All @@ -210,6 +210,12 @@ jobs:
run: |
files=$(ls dist/${BIN_NAME}*)
gh release upload "${GIT_REF}" ${files}
- name: Restore build script seed
if: startsWith(github.ref_name, 'clang-tools-manager/v')
uses: actions/download-artifact@v8
with:
name: ${{ needs.seed-build-script.outputs.artifact-name }}
path: clang-tools-manager
- name: Establish provenance
id: auth
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
Expand Down
5 changes: 4 additions & 1 deletion clang-tools-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ homepage.workspace = true
license.workspace = true
edition.workspace = true
repository.workspace = true
# Include a pre-seeded versions.json file in package published to crates.io.
# This is invalidated after 24 hours, but it allows docs.rs builds to succeed.
include = ["versions.json", "src/**", "Cargo.toml", "README.md", "build.rs", "tests/**"]

[[bin]]
path = "src/main.rs"
Expand All @@ -21,7 +24,7 @@ required-features = ["bin"]
[dependencies]
anyhow = { workspace = true, optional = true }
blake2 = "0.10.6"
clap = { workspace = true, features = ["derive", "env"], optional = true }
clap = { workspace = true, features = ["derive"], optional = true }
colored = { workspace = true, optional = true }
directories = "6.0.0"
log = { workspace = true }
Expand Down
30 changes: 26 additions & 4 deletions clang-tools-manager/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use std::{fs, path::PathBuf, time::Duration};
use std::{
fs,
io::Write,
path::PathBuf,
time::{Duration, SystemTime},
};

use reqwest::blocking::ClientBuilder;

Expand All @@ -11,11 +16,19 @@ struct VersionInfo {
}
fn main() {
let pre_seed = PathBuf::from("versions.json");
let version_info_str = if pre_seed.exists() {
let version_info_str = if pre_seed.exists()
&& let Ok(metadata) = fs::metadata(&pre_seed)
&& metadata.modified().is_ok_and(|d| {
SystemTime::now()
.duration_since(d)
// repopulate cached file in case of error
.unwrap_or(Duration::from_hours(25))
< Duration::from_hours(24)
}) {
println!("cargo:warning=Using pre-seeded version info from {pre_seed:?}");
fs::read_to_string(&pre_seed).unwrap()
} else {
ClientBuilder::new()
let versions = ClientBuilder::new()
.user_agent("cpp-linter-rs/clang-tools-manager")
.timeout(Duration::from_secs(30))
.build()
Expand All @@ -24,7 +37,16 @@ fn main() {
.send()
.unwrap()
.text()
.unwrap()
.unwrap();
let mut cached_seed = fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&pre_seed)
.unwrap();
cached_seed.write_all(versions.as_bytes()).unwrap();
cached_seed.set_modified(SystemTime::now()).unwrap();
versions
};
let version_info: VersionInfo = serde_json::from_str(&version_info_str).unwrap();
let (min_ver, max_ver) = {
Expand Down