Skip to content

Preparation for crates.io publishing #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 20, 2025
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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- name: Run tests
run: cargo test --target=${{ matrix.target.arch }} --verbose
if: ${{ matrix.target.skip-test != true }}
- name: Publish dry-run
run: cargo publish --dry-run -p csaf-rs --target=${{ matrix.target.arch }} --verbose
if: ${{ matrix.target.skip-test != true }}
- name: Archive csaf-validator (${{ matrix.target.arch }})
uses: actions/upload-artifact@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["csaf-validator", "csaf-lib"]
members = ["csaf-validator", "csaf-rs"]
resolver = "2"
File renamed without changes.
9 changes: 7 additions & 2 deletions csaf-lib/Cargo.toml → csaf-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[package]
name = "csaf-lib"
version = "0.1.0"
name = "csaf-rs"
description = "A parser for the CSAF standard written in Rust"
license = "Apache-2.0"
repository = "http://github.com/csaf-poc/csaf-rust"
keywords = ["csaf"]
readme = "../README.md"
version = "0.1.2"
edition = "2021"

[dependencies]
Expand Down
19 changes: 17 additions & 2 deletions csaf-lib/build.rs → csaf-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ pub enum BuildError {
}

fn main() -> Result<(), BuildError> {
// We only need to generate these files as part of our cargo build process,
// not if we are publishing or getting built by cargo from a crates.io
// package. This is because the files are generated from the JSON schema
// files, which are not included in the published package.
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
if manifest_dir.to_string_lossy().contains("target/package") {
// If we're in target/package/<version>, we don't need to generate the files
// because they are already generated in the package.
return Ok(());
} else if manifest_dir.to_string_lossy().contains("crates.io") {
// If we're in a crates.io folder we don't need to generate the files
// because they are already generated in the debug build.
return Ok(());
}

build(
"./src/csaf/csaf2_0/csaf_json_schema.json",
"csaf/csaf2_0/schema.rs",
Expand All @@ -42,8 +57,8 @@ fn main() -> Result<(), BuildError> {
Ok(())
}

fn build(input: &str, output: &str, no_date_time: bool) -> Result<(), BuildError> {
let content = fs::read_to_string(input)?;
fn build(input: &str, output: &str, no_date_time: bool) -> Result<(), BuildError> {
let content = fs::read_to_string(&input)?;
let mut schema_value = serde_json::from_str(&content)?;
if no_date_time {
// Recursively search for "format": "date-time" and remove this format
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions csaf-validator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[package]
name = "csaf-validator"
version = "0.1.0"
description = "A validator for the CSAF standard written in Rust"
license = "Apache-2.0"
repository = "http://github.com/csaf-poc/csaf-rust"
keywords = ["csaf"]
readme = "../README.md"
version = "0.1.2"
edition = "2021"

[dependencies]
csaf-lib = { path = "../csaf-lib" }
csaf-rs = { path = "../csaf-rs", version = "0.1.2" }
anyhow = "1.0.93"
clap = { version = "4.5.23", features = ["derive"] }
6 changes: 3 additions & 3 deletions csaf-validator/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::str::FromStr;
use anyhow::{bail, Result};
use csaf_lib::csaf::csaf2_0::loader::load_document as load_document_2_0;
use csaf_lib::csaf::csaf2_1::loader::load_document as load_document_2_1;
use csaf_lib::csaf::validation::{validate_by_preset, validate_by_test, Validatable, ValidationPreset};
use csaf_rs::csaf::csaf2_0::loader::load_document as load_document_2_0;
use csaf_rs::csaf::csaf2_1::loader::load_document as load_document_2_1;
use csaf_rs::csaf::validation::{validate_by_preset, validate_by_test, Validatable, ValidationPreset};
use clap::Parser;

/// A validator for CSAF documents
Expand Down