From 2c25b1df24c22a61cc998d2470dea7f8fce8bfdb Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 27 May 2024 15:29:35 -0400 Subject: [PATCH] fix: fully version schema (#152) Signed-off-by: Todd Baert --- .github/workflows/pr-checks.yml | 25 ++++++++++++++++++------- .github/workflows/release-please.yaml | 3 ++- json/flags.json | 2 +- json/flags.yaml | 2 +- json/targeting.json | 2 +- json/targeting.yaml | 2 +- json/version.txt | 1 + release-please-config.json | 6 +++++- 8 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 json/version.txt diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 597ac01..8697777 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -5,6 +5,7 @@ on: permissions: contents: read + contents: write env: GO_VERSION: 1.22 @@ -44,7 +45,7 @@ jobs: with: github_token: ${{ github.token }} - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Run breaking change detection against the last commit - uses: bufbuild/buf-breaking-action@v1 with: @@ -52,10 +53,12 @@ jobs: against: 'https://github.com/open-feature/schemas.git#branch=main,ref=HEAD~1,subdir=protobuf' - validate-schema: + validate-and-sync-schema: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} # Use ajv to validate schema - name: Setup node @@ -72,9 +75,17 @@ jobs: - name: Validate Schema run: make test - # Ensure there is no diff when make gen-schema-json is run - - run: make gen-schema-json - - name: Check no diff + # Sync JSON schemas from YAML versions + - name: Sync JSON from YAML run: | - if [ ! -z "$(git status --porcelain)" ]; then echo "JSON schema generation produced diff. Run 'make gen-schema-json' and commit results."; exit 1; fi + make gen-schema-json + if [ ! -z "$(git status --porcelain)" ]; then + echo "JSON schema generation produced diff, regenerating and committing result..."; + git config --global user.name "validate-and-sync-schema-job" + git config --global user.email "bot@openfeature.dev" + git add json/*.json && git commit --amend --no-edit + git push + else + echo "No delta between YAML and JSON schemas, finishing..." + fi diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 5e62bda..e93e4df 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -21,8 +21,9 @@ jobs: id: release with: command: manifest - token: ${{secrets.GITHUB_TOKEN}} + token: ${{secrets.RELEASE_PLEASE_ACTION_TOKEN}} default-branch: main + signoff: "OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>" outputs: releases_created: ${{ steps.release.outputs.releases_created }} # these are generated by release-please b/c this is in a manifest repo. diff --git a/json/flags.json b/json/flags.json index a6a09a7..a6de9d8 100644 --- a/json/flags.json +++ b/json/flags.json @@ -1,5 +1,5 @@ { - "$id": "https://flagd.dev/schema/v0/flags.json", + "$id": "https://flagd.dev/schema/v0.2.5/flags.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "flagd Flag Configuration", "description": "Defines flags for use in flagd, including typed variants and rules", diff --git a/json/flags.yaml b/json/flags.yaml index 3a18693..ded63c4 100644 --- a/json/flags.yaml +++ b/json/flags.yaml @@ -1,4 +1,4 @@ -$id: "https://flagd.dev/schema/v0/flags.json" +$id: "https://flagd.dev/schema/v0.2.5/flags.json" # x-release-please-version $schema: http://json-schema.org/draft-07/schema# title: flagd Flag Configuration description: Defines flags for use in flagd, including typed variants and rules diff --git a/json/targeting.json b/json/targeting.json index 3818343..e405f46 100644 --- a/json/targeting.json +++ b/json/targeting.json @@ -1,5 +1,5 @@ { - "$id": "https://flagd.dev/schema/v0/targeting.json", + "$id": "https://flagd.dev/schema/v0.2.5/targeting.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "flagd Targeting", "description": "Defines targeting logic for flagd; a extension of JSONLogic, including purpose-built feature-flagging operations.", diff --git a/json/targeting.yaml b/json/targeting.yaml index 5e726c8..c237bef 100644 --- a/json/targeting.yaml +++ b/json/targeting.yaml @@ -1,4 +1,4 @@ -$id: "https://flagd.dev/schema/v0/targeting.json" +$id: "https://flagd.dev/schema/v0.2.5/targeting.json" # x-release-please-version $schema: http://json-schema.org/draft-07/schema# title: flagd Targeting description: Defines targeting logic for flagd; a extension of JSONLogic, including diff --git a/json/version.txt b/json/version.txt new file mode 100644 index 0000000..28af839 --- /dev/null +++ b/json/version.txt @@ -0,0 +1 @@ +0.2.5 \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json index c66c4f8..4116ac2 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -14,7 +14,11 @@ "release-type": "simple", "prerelease": false, "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": true + "bump-patch-for-minor-pre-major": true, + "extra-files": [ + "flags.yaml", + "targeting.yaml" + ] } }, "changelog-sections": [