|
1 | 1 | on: |
2 | 2 | repository_dispatch: |
3 | | - types: [spec_release] |
4 | | -#on: push |
| 3 | + types: [release] |
| 4 | + workflow_dispatch: |
| 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: '' |
5 | 15 |
|
6 | 16 | name: Generate VRChat API SDK |
7 | 17 |
|
8 | 18 | jobs: |
9 | 19 | generate: |
10 | 20 | runs-on: ubuntu-latest |
11 | 21 | name: Generate VRChat API SDK |
| 22 | + env: |
| 23 | + ARTIFACT_NAME: "openapi.yaml" |
| 24 | + INPUT: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json }} |
| 25 | + SPEC_URL: ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['artifacts']['openapi-legacy.yaml'] }} |
| 26 | + PASSED_VERSION: ${{ fromJSON(github.event_name == 'repository_dispatch' && github.event.client_payload || inputs.json)['version'] }} |
| 27 | + VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }} |
12 | 28 | steps: |
13 | 29 | - uses: actions/setup-node@v3 |
14 | 30 | with: |
15 | 31 | node-version: 16 |
| 32 | + |
16 | 33 | - uses: actions/checkout@v3 |
| 34 | + |
17 | 35 | - name: 'Cache node_modules' |
18 | 36 | uses: actions/cache@v3 |
19 | 37 | with: |
20 | 38 | path: node_modules |
21 | 39 | key: ${{ runner.os }}-node-v16-${{ hashFiles('**/generate.sh') }} |
22 | 40 | restore-keys: | |
23 | 41 | ${{ runner.os }}-node-v16 |
| 42 | +
|
24 | 43 | - name: Install OpenAPI Generator CLI |
25 | 44 | run: npm install @openapitools/openapi-generator-cli |
| 45 | + |
26 | 46 | - name: Set OpenAPI Generator version |
27 | 47 | run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 6.2.1 |
28 | | - - name: Generate SDK Client |
29 | | - run: bash ./generate.sh |
| 48 | + |
| 49 | + - name: Download Specification |
| 50 | + run: wget "${SPEC_URL}" '--output-document' "${ARTIFACT_NAME}" |
| 51 | + |
30 | 52 | - name: Check version number |
31 | 53 | run: | |
32 | | - echo "spec_version=$(grep "version =" build.gradle | cut -d "'" -f 2)" >> $GITHUB_ENV |
33 | | - - name: Print version number |
34 | | - run: echo ${{ env.spec_version }} |
| 54 | + vrchat_sdk_version=$(( ${PASSED_VERSION%%.*} + 1)).${PASSED_VERSION#*.}${VERSION_POSTPEND} |
| 55 | + echo "Version is: ${vrchat_sdk_version}" |
| 56 | + echo "vrchat_sdk_version=$vrchat_sdk_version" >> $GITHUB_ENV |
| 57 | +
|
| 58 | + - name: Generate SDK Client |
| 59 | + run: bash ./generate.sh "${ARTIFACT_NAME}" "${vrchat_sdk_version}" |
| 60 | + |
35 | 61 | - name: Deploy SDK back into main branch and make tag |
36 | 62 | uses: JamesIves/github-pages-deploy-action@v4 |
37 | 63 | with: |
38 | 64 | branch: main |
39 | 65 | folder: . |
40 | | - commit-message: "Upgrade Java SDK to spec ${{ env.spec_version }}" |
41 | | - tag: ${{ env.spec_version }} |
| 66 | + commit-message: "Upgrade Java SDK to spec ${{vrchat_sdk_version}}" |
| 67 | + tag: ${{vrchat_sdk_version}} |
42 | 68 |
|
43 | 69 | # gradle: |
44 | 70 | # runs-on: ubuntu-latest |
|
0 commit comments