Skip to content

Commit 6876274

Browse files
authored
Preparation for crates.io publishing (#44)
1 parent 80d6772 commit 6876274

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+42
-14
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- name: Run tests
4242
run: cargo test --target=${{ matrix.target.arch }} --verbose
4343
if: ${{ matrix.target.skip-test != true }}
44+
- name: Publish dry-run
45+
run: cargo publish --dry-run -p csaf-rs --target=${{ matrix.target.arch }} --verbose
46+
if: ${{ matrix.target.skip-test != true }}
4447
- name: Archive csaf-validator (${{ matrix.target.arch }})
4548
uses: actions/upload-artifact@v4
4649
with:

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[workspace]
2-
members = ["csaf-validator", "csaf-lib"]
2+
members = ["csaf-validator", "csaf-rs"]
33
resolver = "2"
File renamed without changes.

csaf-lib/Cargo.toml renamed to csaf-rs/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[package]
2-
name = "csaf-lib"
3-
version = "0.1.0"
2+
name = "csaf-rs"
3+
description = "A parser for the CSAF standard written in Rust"
4+
license = "Apache-2.0"
5+
repository = "http://github.com/csaf-poc/csaf-rust"
6+
keywords = ["csaf"]
7+
readme = "../README.md"
8+
version = "0.1.2"
49
edition = "2021"
510

611
[dependencies]

csaf-lib/build.rs renamed to csaf-rs/build.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ pub enum BuildError {
1818
}
1919

2020
fn main() -> Result<(), BuildError> {
21+
// We only need to generate these files as part of our cargo build process,
22+
// not if we are publishing or getting built by cargo from a crates.io
23+
// package. This is because the files are generated from the JSON schema
24+
// files, which are not included in the published package.
25+
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
26+
if manifest_dir.to_string_lossy().contains("target/package") {
27+
// If we're in target/package/<version>, we don't need to generate the files
28+
// because they are already generated in the package.
29+
return Ok(());
30+
} else if manifest_dir.to_string_lossy().contains("crates.io") {
31+
// If we're in a crates.io folder we don't need to generate the files
32+
// because they are already generated in the debug build.
33+
return Ok(());
34+
}
35+
2136
build(
2237
"./src/csaf/csaf2_0/csaf_json_schema.json",
2338
"csaf/csaf2_0/schema.rs",
@@ -42,8 +57,8 @@ fn main() -> Result<(), BuildError> {
4257
Ok(())
4358
}
4459

45-
fn build(input: &str, output: &str, no_date_time: bool) -> Result<(), BuildError> {
46-
let content = fs::read_to_string(input)?;
60+
fn build(input: &str, output: &str, no_date_time: bool) -> Result<(), BuildError> {
61+
let content = fs::read_to_string(&input)?;
4762
let mut schema_value = serde_json::from_str(&content)?;
4863
if no_date_time {
4964
// Recursively search for "format": "date-time" and remove this format
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)