Skip to content

Generate VRChat API SDK #111

Generate VRChat API SDK

Generate VRChat API SDK #111

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:
ARTIFACT_NAME: "openapi.json"
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: Download Specification
run: wget "${SPEC_URL}"
- name: Check version number
run: |
set -euo pipefail
if [ "$(yq '--unwrapScalar' '.info.version' "${ARTIFACT_NAME}")" != ${PASSED_VERSION} ]
then
echo -e "Mismatch between actual and expected version!\nAborting Release." >&2
exit 1
fi
- name: Apply Version Postpend
if: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix != '' }}
run: yq '--inplace' ".info.version |= \"${PASSED_VERSION}${VERSION_POSTPEND}\"" "${ARTIFACT_NAME}"
- name: Generate SDK Client
run: bash ./generate.sh "${ARTIFACT_NAME}"
- name: Check version number
run: |
set -euo pipefail
if [ "$(yq '--unwrapScalar' '--input-format=toml' '--output-format=toml' '.package.version' 'Cargo.toml')" != "${PASSED_VERSION}${VERSION_POSTPEND}" ]
then
echo -e "Mismatch between actual and expected version!\nAborting Release." >&2
exit 1
fi
- name: Remove API Spec
run: unlink "${ARTIFACT_NAME}"
- 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