Skip to content

Update schema

Update schema #315

Workflow file for this run

name: Update schema
concurrency: update-schema-${{ github.ref }}
on:
workflow_dispatch:
inputs:
ref:
description: "New axone-protocol/contracts version (repository tag or repository ref)"
required: true
draft:
type: boolean
description: "Indicate if schemas need to be only publish in draft or need to be released and published publicly"
required: false
default: false
jobs:
update-schema:
runs-on: ubuntu-22.04
steps:
- name: Checks params
run: |
if [[ ! ${{ github.event.inputs.ref }} =~ ^v[0-9]+(\.[0-9]+)* ]] && [[ ! ${{ github.event.inputs.ref }} = "main" ]]; then
>&2 echo "❌ Invalid github ref given '${{ github.event.inputs.ref }}', should be eithier 'main' or 'v*'."
exit 1
fi
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ secrets.OPS_TOKEN }}
fetch-depth: 2
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.cargo/bin
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Setup rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.75
default: true
override: true
- name: Install cargo make
uses: davidB/rust-cargo-make@v1
- name: Install Mage
run: go install github.com/magefile/[email protected]
- name: Download & generate schema
run: |
mage -v schema:generate ${{ github.event.inputs.ref }}
- name: Generate readme
run: |
mage -v schema:readme ${{ github.event.inputs.ref }}
- name: Upload artefact
uses: actions/upload-artifact@v4
with:
name: schema
path: ./
retention-days: 1
overwrite: true
schema-matrix:
runs-on: ubuntu-22.04
needs: update-schema
outputs:
schema: ${{ steps.set-matrix.outputs.schema }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "::set-output name=schema::$(ls schema/ | jq -R -s -c 'split("\n")[:-1] | map(select(test(".json$") | not))')"
build-target:
runs-on: ubuntu-22.04
needs: schema-matrix
strategy:
matrix:
target: [ts, go]
schema: ${{ fromJson(needs.schema-matrix.outputs.schema) }}
max-parallel: 1
steps:
- name: Download artefact
uses: actions/download-artifact@v4
with:
name: schema
path: ./
- name: Setup node environment (for building)
uses: actions/setup-node@v4
with:
node-version: 18.12.0
- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Install Mage
run: go install github.com/magefile/[email protected]
- name: Build
run: |
mage -v build:${{ matrix.target }} ${{ matrix.schema }}
- name: Upload artefact
uses: actions/upload-artifact@v4
with:
name: schema
path: ./
retention-days: 1
overwrite: true
publish-new-schema:
runs-on: ubuntu-22.04
needs: build-target
steps:
- name: Download artefact
uses: actions/download-artifact@v4
with:
name: schema
path: ./
- name: Setup Go environment
uses: actions/setup-go@v5
if: ${{ github.event.inputs.draft == 'false' }}
with:
go-version: "1.22"
cache: true
cache-dependency-path: |
**/go.sum
**/go.mod
- name: Install Mage
if: ${{ github.event.inputs.draft == 'false' }}
run: go install github.com/magefile/[email protected]
- name: "Bump ts version"
if: ${{ github.event.inputs.draft == 'false' }}
run: |
mage -v bumpVersion:ts ${{ github.event.inputs.ref }}
- name: "Bump go version"
if: ${{ github.event.inputs.draft == 'false' }}
run: |
mage -v bumpVersion:go ${{ github.event.inputs.ref }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit documentation draft
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_user_name: ${{ vars.BOT_GIT_COMMITTER_NAME }}
commit_user_email: ${{ vars.BOT_GIT_COMMITTER_EMAIL }}
commit_author: ${{ vars.BOT_GIT_AUTHOR_NAME }} <${{ vars.BOT_GIT_AUTHOR_EMAIL }}>
commit_message: "${{ github.event.inputs.draft == 'true' && 'feat: update schema files' || 'chore(release): perform release' }} ${{ github.event.inputs.draft == 'false' && github.event.inputs.ref || '' }}"
tagging_message: ${{ github.event.inputs.draft == 'false' && github.event.inputs.ref || '' }}
file_pattern: '*.json */README.md go/**/*.go'