Skip to content

Generate VRChat API SDK #107

Generate VRChat API SDK

Generate VRChat API SDK #107

Workflow file for this run

on:
repository_dispatch:
types: [release]
workflow_dispatch:
inputs:
json:
description: 'Passed json from repository_dispatch'
required: true
type: string
version_postfix:
description: 'Additional string to concatenate onto the existing version before release'
required: false
type: string
default: ''
name: Generate VRChat API SDK
jobs:
generate:
runs-on: ubuntu-latest
name: Generate VRChat API SDK
env:
INPUT: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json }}
SPEC_URL: ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['artifacts']['openapi.json'] }}
PASSED_VERSION: ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['version'] }}
VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }}
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/checkout@v4
- name: 'Cache node_modules'
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-v22-${{ hashFiles('**/generate.sh') }}
restore-keys: |
${{ runner.os }}-node-v22
- name: Install OpenAPI Generator CLI
run: npm install @openapitools/openapi-generator-cli
- name: Set OpenAPI Generator version
run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 7.17.0
- name: Set up JDK 20
uses: actions/setup-java@v4
with:
java-version: '20'
distribution: 'adopt'
- name: Install Rustup toolchain
uses: moonrepo/setup-rust@v1
- name: Generate SDK Client
run: bash ./generate.sh ${SPEC_URL}
- name: Check version number
run: |
set -euo pipefail
VERSION=
if [ "$(tomlq .package.version Cargo.toml -r)" != ${PASSED_VERSION}]
then
echo "Mismatch between actual and expected version!\nAborting Release." >&2
exit 1
fi
if [ "${VERSION_POSTPEND}" != "" ]
then
tomlq '.package.version |= "${PASSED_VERSION}${VERSION_POSTPEND}"' Cargo.toml --toml-output --in-place
fi
- name: Deploy SDK back into main branch
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: main
folder: .
commit-message: "Upgrade Rust SDK to spec ${{ env.PASSED_VERSION }}${{env.VERSION_POSTPEND}}"
- name: Deploy to Crates.io
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
args: --allow-dirty