Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
on:
repository_dispatch:
types: [spec_release]
types: [release]
workflow_dispatch:
#on: push
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:
Expand All @@ -34,18 +48,26 @@ jobs:
- name: Install Rustup toolchain
uses: moonrepo/setup-rust@v1
- name: Generate SDK Client
run: bash ./generate.sh
run: bash ./generate.sh ${SPEC_URL}
- name: Check version number
run: |
echo "spec_version=$(grep "^version" ./Cargo.toml | cut -d "\"" -f 2)" >> $GITHUB_ENV
- name: Print version number
run: echo ${{ env.spec_version }}
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.spec_version }}"
commit-message: "Upgrade Rust SDK to spec ${{ env.PASSED_VERSION }}${{env.VERSION_POSTPEND}}"
- name: Deploy to Crates.io
uses: katyo/publish-crates@v2
with:
Expand Down
9 changes: 8 additions & 1 deletion generate.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail

if [ ${#} -le 0 ]
then
echo "Usage: generate.sh <openapi.json>" >&2
exit 1
fi

# Generate Client
rm src/apis src/models docs -rf
Expand All @@ -9,7 +16,7 @@ rm src/apis src/models docs -rf
--git-user-id=vrchatapi \
--git-repo-id=vrchatapi-rust \
-o . \
-i https://raw.githubusercontent.com/vrchatapi/specification/gh-pages/openapi.yaml \
-i "${1}" \
--http-user-agent="vrchatapi-rust"
#--global-property debugOperations=true

Expand Down