Skip to content

Generate VRChat API SDK #121

Generate VRChat API SDK

Generate VRChat API SDK #121

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.yaml"
INPUT: ${{ github.event_name == 'repository_dispatch' && toJSON(github.event.client_payload) || inputs.json }}
SPEC_URL: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json))['artifacts']['openapi-legacy.yaml'] }}
PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(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: Setup NuGet
uses: NuGet/setup-nuget@v1.1.1
- uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Download Specification
run: wget "${SPEC_URL}" '--output-document' "${ARTIFACT_NAME}"
- name: Check version number
run: |
vrchat_sdk_version=$(( ${PASSED_VERSION%%.*} + 1)).${PASSED_VERSION#*.}${VERSION_POSTPEND}
echo "Version is: ${vrchat_sdk_version}"
echo "vrchat_sdk_version=$vrchat_sdk_version" >> $GITHUB_ENV
- name: Generate SDK Client
run: bash ./generate.sh "${ARTIFACT_NAME}" "${vrchat_sdk_version}"
- name: Copy README.md into src/
run: cp README.md src/
- name: Delete openapi.json file
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 .NET SDK to spec ${{ env.vrchat_sdk_version }}"
- name: Publish to VRChat.API to NuGet
uses: pairbit/publish-nuget@v2.5.8
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: src/VRChat.API/VRChat.API.csproj
# NuGet package id, used for version detection & defaults to project name
PACKAGE_NAME: VRChat.API
# API key to authenticate with NuGet server
NUGET_KEY: ${{secrets.NUGET_KEY}}
# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org
# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
INCLUDE_SYMBOLS: true
- name: Publish to VRChat.API.Extensions.Hosting to NuGet
uses: pairbit/publish-nuget@v2.5.8
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: wrapper/VRChat.API.Extensions.Hosting/VRChat.API.Extensions.Hosting.csproj
# NuGet package id, used for version detection & defaults to project name
PACKAGE_NAME: VRChat.API.Extensions.Hosting
# API key to authenticate with NuGet server
NUGET_KEY: ${{secrets.NUGET_KEY}}
# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org
# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
INCLUDE_SYMBOLS: true