11on :
22 repository_dispatch :
3- types : [spec_release ]
3+ types : [release ]
44 workflow_dispatch :
5- # on: push
5+ inputs :
6+ json :
7+ description : ' Passed json from repository_dispatch'
8+ required : true
9+ type : string
10+ version_postfix :
11+ description : ' Additional string to concatenate onto the existing version before release'
12+ required : false
13+ type : string
14+ default : ' '
615
716name : Generate VRChat API SDK
817
918jobs :
1019 generate :
1120 runs-on : ubuntu-latest
1221 name : Generate VRChat API SDK
22+ env :
23+ INPUT : ${{ github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json }}
24+ SPEC_URL : ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['artifacts']['openapi.json'] }}
25+ PASSED_VERSION : ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['version'] }}
26+ VERSION_POSTPEND : ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }}
1327 steps :
1428 - uses : actions/setup-node@v4
1529 with :
@@ -34,18 +48,26 @@ jobs:
3448 - name : Install Rustup toolchain
3549 uses : moonrepo/setup-rust@v1
3650 - name : Generate SDK Client
37- run : bash ./generate.sh
51+ run : bash ./generate.sh ${SPEC_URL}
3852 - name : Check version number
3953 run : |
40- echo "spec_version=$(grep "^version" ./Cargo.toml | cut -d "\"" -f 2)" >> $GITHUB_ENV
41- - name : Print version number
42- run : echo ${{ env.spec_version }}
54+ set -euo pipefail
55+ VERSION=
56+ if [ "$(tomlq .package.version Cargo.toml -r)" != ${PASSED_VERSION}]
57+ then
58+ echo "Mismatch between actual and expected version!\nAborting Release." >&2
59+ exit 1
60+ fi
61+ if [ "${VERSION_POSTPEND}" != "" ]
62+ then
63+ tomlq '.package.version |= "${PASSED_VERSION}${VERSION_POSTPEND}"' Cargo.toml --toml-output --in-place
64+ fi
4365 - name : Deploy SDK back into main branch
4466 uses : JamesIves/github-pages-deploy-action@v4
4567 with :
4668 branch : main
4769 folder : .
48- commit-message : " Upgrade Rust SDK to spec ${{ env.spec_version }}"
70+ commit-message : " Upgrade Rust SDK to spec ${{ env.PASSED_VERSION }}${{env.VERSION_POSTPEND }}"
4971 - name : Deploy to Crates.io
5072 uses : katyo/publish-crates@v2
5173 with :
0 commit comments