From e92a325da4bdaf0f537b087a0d9900c98f960437 Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Thu, 4 Dec 2025 02:27:40 +0100 Subject: [PATCH 1/3] Migrate to the new release ci --- .github/workflows/ci.yaml | 36 +++++++++++++++++++++++++++++------- generate.sh | 9 ++++++++- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 903712e..711c65b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,8 +1,17 @@ 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: true + type: string + default: '' name: Generate VRChat API SDK @@ -10,6 +19,11 @@ 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: @@ -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 + 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: diff --git a/generate.sh b/generate.sh index 247f96a..f1228b3 100755 --- a/generate.sh +++ b/generate.sh @@ -1,4 +1,11 @@ #!/usr/bin/env bash +set -euo pipefail + +if [ ${#} -le 0 ] +then + echo "Usage: generate.sh " >&2 + exit 1 +fi # Generate Client rm src/apis src/models docs -rf @@ -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 From 7924e9a81ee16b4fa5f737cceb8f99791f0b32c9 Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Thu, 4 Dec 2025 02:32:39 +0100 Subject: [PATCH 2/3] Actually change the version in the `Cargo.toml` when necessary --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 711c65b..f12eee7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,7 +60,7 @@ jobs: fi if [ "${VERSION_POSTPEND}" != "" ] then - tomlq '.package.version |= "${PASSED_VERSION}${VERSION_POSTPEND}"' Cargo.toml --toml-output + 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 From 9b65dd1929ee08dc131762a8d5d99d98f9c9346f Mon Sep 17 00:00:00 2001 From: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> Date: Thu, 4 Dec 2025 10:59:53 +0100 Subject: [PATCH 3/3] Make `version_postfix` optional --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f12eee7..5624c58 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ on: type: string version_postfix: description: 'Additional string to concatenate onto the existing version before release' - required: true + required: false type: string default: ''