Skip to content

Commit ea368b2

Browse files
authored
Merge pull request #8 from vrchatapi/feat/update-ci
Update CI for new Release CI
2 parents 3eacd03 + 8d0f5c9 commit ea368b2

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

.github/workflows/ci.yaml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,70 @@
11
on:
22
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: ''
515

616
name: Generate VRChat API SDK
717

818
jobs:
919
generate:
1020
runs-on: ubuntu-latest
1121
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 || '' }}
1228
steps:
1329
- uses: actions/setup-node@v3
1430
with:
1531
node-version: 16
32+
1633
- uses: actions/checkout@v3
34+
1735
- name: 'Cache node_modules'
1836
uses: actions/cache@v3
1937
with:
2038
path: node_modules
2139
key: ${{ runner.os }}-node-v16-${{ hashFiles('**/generate.sh') }}
2240
restore-keys: |
2341
${{ runner.os }}-node-v16
42+
2443
- name: Install OpenAPI Generator CLI
2544
run: npm install @openapitools/openapi-generator-cli
45+
2646
- name: Set OpenAPI Generator version
2747
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+
3052
- name: Check version number
3153
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%%.*})).${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}"
60+
3561
- name: Deploy SDK back into main branch and make tag
3662
uses: JamesIves/github-pages-deploy-action@v4
3763
with:
3864
branch: main
3965
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}
4268

4369
# gradle:
4470
# runs-on: ubuntu-latest

.github/workflows/maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
matrix:
2020
java: [ '8' ]
2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Set up JDK
24-
uses: actions/setup-java@v2
24+
uses: actions/setup-java@v3
2525
with:
2626
java-version: ${{ matrix.java }}
2727
distribution: 'temurin'

generate.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

3-
npm install @openapitools/openapi-generator-cli
3+
if [ ${#} -le 0 ]
4+
then
5+
echo "Usage: generate.sh <openapi.yaml>" >&2
6+
exit 1
7+
fi
48

59
rm docs -rf
610
rm src/main/java/io/github/vrchatapi/*.java
@@ -14,7 +18,7 @@ rm src/main/java/io/github/vrchatapi/model -rf
1418
--git-user-id=vrchatapi \
1519
--git-repo-id=vrchatapi-java \
1620
-o . \
17-
-i https://raw.githubusercontent.com/vrchatapi/specification/gh-pages/openapi.yaml \
21+
-i "${1}" \
1822
--http-user-agent="vrchatapi-java"
1923

2024
# Remove unneccesary copy of spec

0 commit comments

Comments
 (0)