Skip to content

Commit f8385c6

Browse files
Update CI for new Release CI (#32)
* Update CI to match dotnet's version * Update generate too * Update .github/workflows/ci.yaml Co-authored-by: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com> * Remove error from copy * Fix wrong commit message --------- Co-authored-by: C0D3 M4513R <28912031+C0D3-M4513R@users.noreply.github.com>
1 parent 77c1eaf commit f8385c6

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,84 @@
11
on:
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

716
name: Generate VRChat API SDK
817

918
jobs:
1019
generate:
1120
runs-on: ubuntu-latest
1221
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 || '' }}
1328
steps:
1429
- uses: actions/setup-node@v1
1530
with:
1631
node-version: 16
32+
1733
- uses: actions/checkout@v2
34+
1835
- name: 'Cache node_modules'
1936
uses: actions/cache@v4
2037
with:
2138
path: node_modules
2239
key: ${{ runner.os }}-node-v16-${{ hashFiles('**/generate.sh') }}
2340
restore-keys: |
2441
${{ runner.os }}-node-v16
42+
2543
- name: Install OpenAPI Generator CLI
2644
run: npm install @openapitools/openapi-generator-cli
45+
2746
- name: Set OpenAPI Generator version
2847
run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 6.2.1
48+
2949
- name: Set up Python 3.9
3050
uses: actions/setup-python@v1
3151
with:
3252
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+
3557
- name: Check version number
3658
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+
4069
- name: Deploy SDK back into main branch
4170
uses: JamesIves/github-pages-deploy-action@v4
4271
with:
4372
branch: main
4473
folder: .
45-
commit-message: "Upgrade Python SDK to spec ${{ env.spec_version }}"
74+
commit-message: "Upgrade Python SDK to spec ${vrchat_sdk_version}"
75+
4676
- name: Install pypa/build
4777
run: python -m pip install build --user
78+
4879
- name: Build a binary wheel and a source tarball
4980
run: python -m build --sdist --wheel --outdir dist/ .
81+
5082
- name: Publish SDK 📦 to PyPI
5183
uses: pypa/gh-action-pypi-publish@release/v1
5284
with:

generate.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
#!/bin/bash
2-
3-
npm install @openapitools/openapi-generator-cli
1+
#!/usr/bin/env bash
42

3+
if [ ${#} -le 1 ]
4+
then
5+
echo "Usage: generate.sh <openapi.yaml> <version>" >&2
6+
exit 1
7+
fi
58
rm vrchatapi docs -rf
69

710
./node_modules/\@openapitools/openapi-generator-cli/main.js generate \
@@ -10,13 +13,12 @@ rm vrchatapi docs -rf
1013
--git-user-id=vrchatapi \
1114
--git-repo-id=vrchatapi-python \
1215
-o . \
13-
-i https://raw.githubusercontent.com/vrchatapi/specification/gh-pages/openapi.yaml \
16+
-i "${1}" \
1417
--http-user-agent="vrchatapi-py"
1518

1619
# Fix description, keywords, etc...
1720
# Echo to trim whitespace
18-
VERSION=`echo $(cat setup.py | grep "The version of the OpenAPI document" | cut -d ":" -f 2)`
19-
sed -i "s/VERSION = \"1.0.0\"/VERSION = \"$VERSION\"/" ./setup.py
21+
sed -i "s/VERSION = \"1.0.0\"/VERSION = \"${2}\"/" ./setup.py
2022
sed -i 's/description="VRChat API Documentation"/description="VRChat API Library for Python"/' ./setup.py
2123
sed -i 's/keywords=\["OpenAPI", "OpenAPI-Generator", "VRChat API Documentation"\]/keywords=["vrchat", "vrchatapi", "vrc"]/' ./setup.py
2224

0 commit comments

Comments
 (0)