|
1 | 1 | on: |
2 | 2 | repository_dispatch: |
3 | | - types: [spec_release] |
| 3 | + types: [release] |
4 | 4 | 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: '' |
6 | 15 |
|
7 | 16 | name: Generate VRChat API SDK |
8 | 17 |
|
9 | 18 | jobs: |
10 | 19 | generate: |
11 | 20 | runs-on: ubuntu-latest |
12 | 21 | name: Generate VRChat API SDK |
| 22 | + env: |
| 23 | + ARTIFACT_NAME: "openapi.yaml" |
| 24 | + INPUT: ${{ github.event_name == 'repository_dispatch' && toJSON(github.event.client_payload) || inputs.json }} |
| 25 | + SPEC_URL: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json))['artifacts']['openapi-legacy.yaml'] }} |
| 26 | + PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json))['version'] }} |
| 27 | + VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }} |
13 | 28 | steps: |
14 | 29 | - uses: actions/setup-node@v1 |
15 | 30 | with: |
16 | 31 | node-version: 16 |
| 32 | + |
17 | 33 | - uses: actions/checkout@v2 |
| 34 | + |
18 | 35 | - name: 'Cache node_modules' |
19 | 36 | uses: actions/cache@v4 |
20 | 37 | with: |
21 | 38 | path: node_modules |
22 | 39 | key: ${{ runner.os }}-node-v16-${{ hashFiles('**/generate.sh') }} |
23 | 40 | restore-keys: | |
24 | 41 | ${{ runner.os }}-node-v16 |
| 42 | +
|
25 | 43 | - name: Install OpenAPI Generator CLI |
26 | 44 | run: npm install @openapitools/openapi-generator-cli |
| 45 | + |
27 | 46 | - name: Set OpenAPI Generator version |
28 | 47 | run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 6.2.1 |
| 48 | + |
29 | 49 | - name: Set up Python 3.9 |
30 | 50 | uses: actions/setup-python@v1 |
31 | 51 | with: |
32 | 52 | python-version: 3.9 |
33 | | - - name: Generate SDK Client |
34 | | - run: bash ./generate.sh |
| 53 | + |
| 54 | + - name: Download Specification |
| 55 | + run: wget "${SPEC_URL}" '--output-document' "${ARTIFACT_NAME}" |
| 56 | + |
35 | 57 | - name: Check version number |
36 | 58 | run: | |
37 | | - echo "spec_version=$(grep "VERSION =" setup.py | cut -d "\"" -f 2)" >> $GITHUB_ENV |
38 | | - - name: Print version number |
39 | | - run: echo ${{ env.spec_version }} |
| 59 | + vrchat_sdk_version=$(( ${PASSED_VERSION%%.*})).${PASSED_VERSION#*.}${VERSION_POSTPEND} |
| 60 | + echo "Version is: ${vrchat_sdk_version}" |
| 61 | + echo "vrchat_sdk_version=$vrchat_sdk_version" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - name: Generate SDK Client |
| 64 | + run: bash ./generate.sh "${ARTIFACT_NAME}" "${vrchat_sdk_version}" |
| 65 | + |
| 66 | + - name: Delete openapi.yaml file |
| 67 | + run: unlink ${ARTIFACT_NAME} |
| 68 | + |
40 | 69 | - name: Deploy SDK back into main branch |
41 | 70 | uses: JamesIves/github-pages-deploy-action@v4 |
42 | 71 | with: |
43 | 72 | branch: main |
44 | 73 | folder: . |
45 | | - commit-message: "Upgrade Python SDK to spec ${{ env.spec_version }}" |
| 74 | + commit-message: "Upgrade Python SDK to spec ${vrchat_sdk_version}" |
| 75 | + |
46 | 76 | - name: Install pypa/build |
47 | 77 | run: python -m pip install build --user |
| 78 | + |
48 | 79 | - name: Build a binary wheel and a source tarball |
49 | 80 | run: python -m build --sdist --wheel --outdir dist/ . |
| 81 | + |
50 | 82 | - name: Publish SDK 📦 to PyPI |
51 | 83 | uses: pypa/gh-action-pypi-publish@release/v1 |
52 | 84 | with: |
|
0 commit comments