diff --git a/.github/workflows/classifier-gate.yml b/.github/workflows/classifier-gate.yml index aebf6e4..f351a50 100644 --- a/.github/workflows/classifier-gate.yml +++ b/.github/workflows/classifier-gate.yml @@ -15,11 +15,14 @@ jobs: with: path: schemata-codegen + - name: Read schemata version + run: echo "SCHEMATA_VERSION=$(cat schemata-codegen/.schemata-version | tr -d '[:space:]')" >> "$GITHUB_ENV" + - name: Checkout schemata uses: actions/checkout@v4 with: repository: nostrability/schemata - ref: v0.3.1 + ref: ${{ env.SCHEMATA_VERSION }} path: schemata - name: Setup Node.js diff --git a/.github/workflows/compile-check.yml b/.github/workflows/compile-check.yml index 299e831..56a8bed 100644 --- a/.github/workflows/compile-check.yml +++ b/.github/workflows/compile-check.yml @@ -25,11 +25,14 @@ jobs: - name: Build codegen run: npm run build + - name: Read schemata version + run: echo "SCHEMATA_VERSION=$(cat .schemata-version | tr -d '[:space:]')" >> "$GITHUB_ENV" + - name: Download schemata schemas run: | - gh release download v0.3.0 -R nostrability/schemata -p '*.zip' -D /tmp + gh release download "$SCHEMATA_VERSION" -R nostrability/schemata -p '*.zip' -D /tmp mkdir -p /tmp/schemata-dist - unzip -q /tmp/schemata-v0.3.0.zip -d /tmp/schemata-dist + unzip -q /tmp/schemata-*.zip -d /tmp/schemata-dist echo "SCHEMAS_DIR=/tmp/schemata-dist" >> "$GITHUB_ENV" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/update-schemata.yml b/.github/workflows/update-schemata.yml new file mode 100644 index 0000000..e78f810 --- /dev/null +++ b/.github/workflows/update-schemata.yml @@ -0,0 +1,75 @@ +name: Update schemata version + +on: + repository_dispatch: + types: [schema-update] + workflow_dispatch: + inputs: + tag: + description: "Schemata release tag (e.g. v0.4.0)" + required: true + +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - name: Determine tag + run: | + if [ "${{ github.event_name }}" = "repository_dispatch" ]; then + TAG="${{ github.event.client_payload.tag }}" + else + TAG="${{ github.event.inputs.tag }}" + fi + if [ -z "$TAG" ]; then + echo "::error::Missing TAG — neither client_payload.tag nor inputs.tag was set" >&2 + exit 1 + fi + echo "TAG=$TAG" >> "$GITHUB_ENV" + echo "BRANCH=chore/bump-schemata-${TAG}" >> "$GITHUB_ENV" + + - uses: actions/checkout@v4 + with: + token: ${{ secrets.CODEGEN_PAT }} + + - name: Check if already up to date + run: | + CURRENT="$(cat .schemata-version | tr -d '[:space:]')" + if [ "$CURRENT" = "$TAG" ]; then + echo "Already at $TAG — nothing to do." + echo "SKIP=true" >> "$GITHUB_ENV" + fi + + - name: Close existing bump PRs + if: env.SKIP != 'true' + run: | + gh pr list --state open --head "chore/bump-schemata-" --json number --jq '.[].number' \ + | xargs -I{} gh pr close {} --comment "Superseded by bump to $TAG" || true + env: + GH_TOKEN: ${{ secrets.CODEGEN_PAT }} + + - name: Create branch and update version + if: env.SKIP != 'true' + run: | + git checkout -b "$BRANCH" + echo "$TAG" > .schemata-version + git add .schemata-version + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git commit -m "chore: bump schemata to $TAG" + git push --force-with-lease -u origin "$BRANCH" + + - name: Create pull request + if: env.SKIP != 'true' + run: | + gh pr create \ + --title "chore: bump schemata to $TAG" \ + --body "Automated bump triggered by upstream schemata release. + + - Updates \`.schemata-version\` to \`$TAG\` + - CI (classifier-gate + compile-check) will validate compatibility + + If CI fails, new unclassified patterns may need attention." \ + --head "$BRANCH" \ + --base main + env: + GH_TOKEN: ${{ secrets.CODEGEN_PAT }} diff --git a/.schemata-version b/.schemata-version new file mode 100644 index 0000000..937cd78 --- /dev/null +++ b/.schemata-version @@ -0,0 +1 @@ +v0.3.1