From 164e2595ffd5d5ebf9f9ec07efd327ae48edd313 Mon Sep 17 00:00:00 2001 From: ok-nick Date: Fri, 24 Oct 2025 15:42:09 -0400 Subject: [PATCH 1/2] ci: update doc schemas on c2pa-rs release --- .github/workflows/update-schemas.yml | 94 ++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/update-schemas.yml diff --git a/.github/workflows/update-schemas.yml b/.github/workflows/update-schemas.yml new file mode 100644 index 0000000..d78f0ba --- /dev/null +++ b/.github/workflows/update-schemas.yml @@ -0,0 +1,94 @@ +name: Update schemas to latest +on: + repository_dispatch: + types: [c2pa-rs-release] + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + update-schemas: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Checkout json-manifest-reference repository + uses: actions/checkout@v5 + with: + repository: contentauth/json-manifest-reference + path: ./json-manifest-reference + + - name: Checkout c2pa-rs repository + uses: actions/checkout@v5 + with: + repository: contentauth/c2pa-rs + path: ./c2pa-rs + fetch-depth: 0 + + - name: Get latest c2pa-rs version + working-directory: ./c2pa-rs + run: | + latest_tag=$(git tag -l "c2pa-v*" --sort=-v:refname | head -n 1) + echo "latest_tag=$latest_tag" >> $GITHUB_ENV + echo "$latest_tag" + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + + - name: Build schemas + working-directory: ./c2pa-rs + run: cargo run --bin export_schema + + - name: Move new schemas into ./json-manifest-reference/_data + run: cp ./c2pa-rs/target/schema/* ./json-manifest-reference/_data/ + + - name: Check schemas for diff + id: diffs + working-directory: ./json-manifest-reference + run: | + if [ -n "$(git status --porcelain -- ./_data/)" ]; then + echo "diff=true" >> "$GITHUB_OUTPUT" + echo "true" + else + echo "diff=false" >> "$GITHUB_OUTPUT" + echo "false" + fi + + - name: Install Ruby and build and cache dependencies + if: steps.diffs.outputs.diff == 'true' + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7.4' + bundler-cache: true + working-directory: ./json-manifest-reference + + - name: Build Jekyll + if: steps.diffs.outputs.diff == 'true' + working-directory: ./json-manifest-reference + run: bundle exec jekyll build + + - name: Move new built schemas into ./docs/manifest/json-ref + if: steps.diffs.outputs.diff == 'true' + # TODO: ideally we don't hardcode these paths, but we need to sort out a fix in the docs + run: | + cp ./json-manifest-reference/_site/manifest-def.html ./docs/manifest/json-ref + cp ./json-manifest-reference/_site/reader.html ./docs/manifest/json-ref + cp ./json-manifest-reference/_site/settings.html ./docs/manifest/json-ref + + - name: Send schema PR + if: steps.diffs.outputs.diff == 'true' + uses: peter-evans/create-pull-request@v7 + with: + title: 'docs(schema): update schemas to ${{ env.latest_tag }}' + body: 'Updates schemas to ${{ env.latest_tag }}.' + commit-message: 'docs(schema): update schemas to ${{ env.latest_tag }}' + branch: 'schema-${{ env.latest_tag }}' + add-paths: ./docs/manifest/json-ref/* + base: ${{ github.event.repository.default_branch }} From 7a7e2c65c019eec4dd3fd00d5f9b5140c3f3116d Mon Sep 17 00:00:00 2001 From: ok-nick Date: Wed, 29 Oct 2025 14:29:33 -0400 Subject: [PATCH 2/2] ci: fix schema naming compatibility with Ruby/Jekyll --- .github/workflows/update-schemas.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-schemas.yml b/.github/workflows/update-schemas.yml index d78f0ba..844ac09 100644 --- a/.github/workflows/update-schemas.yml +++ b/.github/workflows/update-schemas.yml @@ -47,7 +47,14 @@ jobs: run: cargo run --bin export_schema - name: Move new schemas into ./json-manifest-reference/_data - run: cp ./c2pa-rs/target/schema/* ./json-manifest-reference/_data/ + run: | + # We also rename the schemas to have an underscore in the filename instead of a dot to fix + # compatibility issues with Ruby/Jekyll. + for path in ./c2pa-rs/target/schema/*.schema.json; do + name=$(basename "$path") + new=${name/.schema/_schema} + cp "$path" "./json-manifest-reference/_data/$new" + done - name: Check schemas for diff id: diffs