diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index 2ba1703..3914d77 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -9,10 +9,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: clean: false - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: cache with: path: | diff --git a/ua_generator/build.rs b/ua_generator/build.rs index 0912142..6f50108 100644 --- a/ua_generator/build.rs +++ b/ua_generator/build.rs @@ -30,25 +30,29 @@ fn bump_version_in_cargo_toml() -> Result<(), Box> { let cargo_toml_path = Path::new("Cargo.toml"); let mut cargo_toml_content = String::new(); + crate::fs::OpenOptions::new() .read(true) .open(&cargo_toml_path)? .read_to_string(&mut cargo_toml_content)?; - let mut parsed_toml: Value = cargo_toml_content.parse()?; - if let Some(version) = parsed_toml - .get_mut("package") - .and_then(|pkg| pkg.get_mut("version")) - { - if let Some(version_str) = version.as_str() { - let new_version = increment_version(version_str); - *version = Value::String(new_version.clone()); - println!("Bumped version to: {}", new_version); + if !cargo_toml_content.is_empty() { + let mut parsed_toml: Value = cargo_toml_content.parse()?; + + if let Some(version) = parsed_toml + .get_mut("package") + .and_then(|pkg| pkg.get_mut("version")) + { + if let Some(version_str) = version.as_str() { + let new_version = increment_version(version_str); + *version = Value::String(new_version.clone()); + println!("Bumped version to: {}", new_version); + } } - } - let new_cargo_toml_content = toml::to_string(&parsed_toml)?; - fs::write(cargo_toml_path, new_cargo_toml_content)?; + let new_cargo_toml_content = toml::to_string(&parsed_toml)?; + fs::write(cargo_toml_path, new_cargo_toml_content)?; + } Ok(()) } @@ -74,6 +78,7 @@ fn main() -> Result<(), Box> { let build_enabled = env::var("BUILD_ENABLED").map(|v| v == "1").unwrap_or(false); if build_enabled { + println!("generating user agents..."); let base_api = env::var("API_URL").unwrap_or("https://api.spider.cloud/data/user_agents".into()); @@ -154,6 +159,7 @@ pub fn agents() -> [&'static str; 9] {{ let chrome_agent_list: Vec = match get(&format!("{base_api}?chrome=true&list=true")) .set("apikey", &token) + .set("user-agent", "spider-rs") .call() { Ok(req) => {