Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 101 additions & 52 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,92 +1,141 @@
on:
push:
branches:
- '**'
pull_request:
repository_dispatch:
types: [release]
workflow_dispatch:
inputs:
json:
description: 'Passed json from repository_dispatch'
description: Passed json from repository_dispatch
required: true
type: string
version_postfix:
description: 'Additional string to concatenate onto the existing version before release'
description: Additional string to concatenate onto the existing version before release
required: false
type: string
default: ''
workflow_call:
inputs:
ref:
description: Ref of this repository to build.
required: false
type: string
default: main

name: CI

name: Generate VRChat API SDK
env:
PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json || '{}'))['version'] }}
VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }}
Comment on lines +29 to +31

jobs:
generate:
runs-on: ubuntu-latest
name: Generate VRChat API SDK
env:
ARTIFACT_NAME: "openapi.yaml"
INPUT: ${{ github.event_name == 'repository_dispatch' && toJSON(github.event.client_payload) || inputs.json }}
SPEC_URL: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json))['artifacts']['openapi-legacy.yaml'] }}
PASSED_VERSION: ${{ (github.event_name == 'repository_dispatch' && github.event.client_payload || fromJSON(inputs.json))['version'] }}
VERSION_POSTPEND: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix || '' }}
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/setup-node@v1
- uses: actions/checkout@v7
with:
node-version: 16
repository: vrchatapi/vrchatapi-python
ref: ${{ inputs.ref || github.ref }}

- uses: actions/checkout@v2
- uses: vrchatapi/specification/.github/actions/setup-generator@main

- name: 'Cache node_modules'
uses: actions/cache@v4
- uses: vrchatapi/specification/.github/actions/download@main
with:
path: node_modules
key: ${{ runner.os }}-node-v16-${{ hashFiles('**/generate.sh') }}
restore-keys: |
${{ runner.os }}-node-v16
bundle: openapi-legacy.yaml

- name: Install OpenAPI Generator CLI
run: npm install @openapitools/openapi-generator-cli
# PyPI wants `.dev` where the specification says `-nightly.`
- id: version
run: |
version="${PASSED_VERSION}${VERSION_POSTPEND}"
version="${version:-$(yq -r '.info.version' openapi-legacy.yaml)}"

echo "version=${version/-nightly./.dev}" >> $GITHUB_OUTPUT

- name: Set OpenAPI Generator version
run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 6.2.1
- if: env.VERSION_POSTPEND != ''
run: yq '--inplace' ".info.version |= \"${{ steps.version.outputs.version }}\"" openapi-legacy.yaml

- name: Set up Python 3.14
uses: actions/setup-python@v1
- run: bash ./generate.sh openapi-legacy.yaml "${{ steps.version.outputs.version }}"

- uses: actions/upload-artifact@v7
with:
python-version: 3.14
name: python-generated
path: .
include-hidden-files: true

- name: Download Specification
run: wget "${SPEC_URL}" '--output-document' "${ARTIFACT_NAME}"
build:
needs: generate
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
name: python-generated

- name: Set version
id: version
run: |
# Replace using bash
VERSION="${PASSED_VERSION}${VERSION_POSTPEND}"
CLEAN_VERSION="${VERSION/-nightly./.dev}"
echo "version=${CLEAN_VERSION}" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v7
with:
python-version: '3.14'
cache: pip

- run: python -m pip install build

- run: python -m build --sdist --wheel --outdir dist/ .

- uses: actions/upload-artifact@v7
with:
name: python-package
path: dist

install:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
name: python-package
path: dist

- name: Apply Version Postpend
if: ${{ github.event_name == 'workflow_dispatch' && inputs.version_postfix != '' }}
run: yq '--inplace' ".info.version |= \"${{ steps.version.outputs.version }}\"" "${ARTIFACT_NAME}"
- uses: actions/setup-python@v7
with:
python-version: '3.14'

- name: Generate SDK Client
run: bash ./generate.sh "${ARTIFACT_NAME}" "${{ steps.version.outputs.version }}"
- run: python -m pip install dist/*.whl

- name: Delete openapi.yaml file
run: unlink ${ARTIFACT_NAME}
- run: python -c "import vrchatapi; print(vrchatapi.__name__)"

- name: Deploy SDK back into main branch
uses: JamesIves/github-pages-deploy-action@v4
publish:
needs:
- generate
- build
- install
if: github.repository == 'vrchatapi/vrchatapi-python'
&& (github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
repository: vrchatapi/vrchatapi-python

- uses: actions/download-artifact@v8
with:
name: python-generated

- run: rm -f openapi-legacy.yaml

- uses: JamesIves/github-pages-deploy-action@v4.9.0
with:
branch: main
folder: .
commit-message: "Upgrade Python SDK to spec ${{ steps.version.outputs.version }}"

- name: Install pypa/build
run: python -m pip install build --user
commit-message: Upgrade Python SDK to spec ${{ needs.generate.outputs.version }}

- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- uses: actions/download-artifact@v8
with:
name: python-package
path: dist

- name: Publish SDK 馃摝 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ then
fi
rm vrchatapi docs -rf

./node_modules/\@openapitools/openapi-generator-cli/main.js generate \
openapi-generator generate \
Comment on lines 8 to +10
-g python-legacy \
--additional-properties=packageName=vrchatapi,projectName=vrchatapi \
--git-user-id=vrchatapi \
Expand Down
1 change: 0 additions & 1 deletion openapitools.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.2.1"
Expand Down
Loading
Loading