diff --git a/.github/workflows/bundle_2.0_schemas.yml b/.github/workflows/bundle_2.0_schemas.yml new file mode 100644 index 00000000..01728dda --- /dev/null +++ b/.github/workflows/bundle_2.0_schemas.yml @@ -0,0 +1,59 @@ +name: Bundle CycloneDX 2.0 JSON Schemas + +on: + push: + branches: + - 2.0-dev + - 2.0-dev-threatmodeling + paths: + - 'schema/2.0/**/*.schema.json' + - 'tools/src/main/js/bundler/bundle-schemas.js' + workflow_dispatch: # Allows manual trigger + +jobs: + bundle-schemas: + runs-on: ubuntu-latest + + permissions: + contents: write # Required to push changes + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + working-directory: tools/src/main/js/bundler + run: npm install + + - name: Bundle schemas + working-directory: tools/src/main/js/bundler + run: | + node bundle-schemas.js \ + ../../../../../schema/2.0/model \ + ../../../../../schema/2.0/cyclonedx-2.0.schema.json + + - name: Check for changes and commit + run: | + BUNDLED_FILE="schema/2.0/cyclonedx-2.0-bundled.schema.json" + MINIFIED_FILE="schema/2.0/cyclonedx-2.0-bundled.min.schema.json" + + # Add both files (works for both new and modified files) + git add "$BUNDLED_FILE" "$MINIFIED_FILE" + + # Check if there are staged changes + if git diff --staged --quiet; then + echo "No changes to bundled schemas" + else + echo "Committing bundled schema changes" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "chore: update bundled schemas [skip ci]" + git push + fi \ No newline at end of file diff --git a/docgen/json/gen.sh b/docgen/json/gen.sh index 4eb65326..66db731f 100755 --- a/docgen/json/gen.sh +++ b/docgen/json/gen.sh @@ -2,6 +2,7 @@ set -eu declare -a CDX_VERSIONS=( + '2.0' '1.7' '1.6' '1.5' @@ -44,11 +45,15 @@ generate () { local title="CycloneDX v${version} JSON Reference" echo "Generating: $title" - local SCHEMA_FILE="$SCHEMA_PATH/bom-${version}.schema.json" - local STRICT_SCHEMA_FILE="$SCHEMA_PATH/bom-${version}-strict.schema.json" - if [ -f "$STRICT_SCHEMA_FILE" ] - then + local SCHEMA_FILE + if [[ "$version" == 1.* ]]; then + SCHEMA_FILE="$SCHEMA_PATH/bom-${version}.schema.json" + local STRICT_SCHEMA_FILE="$SCHEMA_PATH/bom-${version}-strict.schema.json" + if [ -f "$STRICT_SCHEMA_FILE" ]; then SCHEMA_FILE="$STRICT_SCHEMA_FILE" + fi + else + SCHEMA_FILE="$SCHEMA_PATH/${version}/cyclonedx-${version}-bundled.schema.json" fi echo "SCHEMA_FILE: $SCHEMA_FILE" diff --git a/docgen/json/requirements.txt b/docgen/json/requirements.txt index d5e43567..dbb2b26d 100644 --- a/docgen/json/requirements.txt +++ b/docgen/json/requirements.txt @@ -1 +1 @@ -json-schema-for-humans==1.3.4 +json-schema-for-humans==1.5.1 diff --git a/docgen/json/templates/cyclonedx/base.html b/docgen/json/templates/cyclonedx/base.html index fd480909..48dc68ef 100644 --- a/docgen/json/templates/cyclonedx/base.html +++ b/docgen/json/templates/cyclonedx/base.html @@ -40,6 +40,8 @@ v${version} (JSON)
All property whose name matches the following regular expression must respect the following conditions
+All properties whose name matches the following regular expression must respect the following conditions
Property name regular expression:{{ sub_property.property_name | escape }}