diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0a361627..141eea1d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,17 @@ on: repository_dispatch: - types: [spec_release] -#on: push + types: [release] + workflow_dispatch: + inputs: + json: + description: 'Passed json from repository_dispatch' + required: true + type: string + version_postfix: + description: 'Additional string to concatenate onto the existing version before release' + required: false + type: string + default: '' name: Generate VRChat API SDK @@ -9,11 +19,19 @@ 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 || '' }} steps: - uses: actions/setup-node@v3 with: node-version: 16 + - uses: actions/checkout@v3 + - name: 'Cache node_modules' uses: actions/cache@v3 with: @@ -21,24 +39,32 @@ jobs: key: ${{ runner.os }}-node-v16-${{ hashFiles('**/generate.sh') }} restore-keys: | ${{ runner.os }}-node-v16 + - name: Install OpenAPI Generator CLI run: npm install @openapitools/openapi-generator-cli + - name: Set OpenAPI Generator version run: ./node_modules/\@openapitools/openapi-generator-cli/main.js version-manager set 6.2.1 - - name: Generate SDK Client - run: bash ./generate.sh + + - name: Download Specification + run: wget "${SPEC_URL}" '--output-document' "${ARTIFACT_NAME}" + - name: Check version number run: | - echo "spec_version=$(grep "version =" build.gradle | cut -d "'" -f 2)" >> $GITHUB_ENV - - name: Print version number - run: echo ${{ env.spec_version }} + vrchat_sdk_version=$(( ${PASSED_VERSION%%.*})).${PASSED_VERSION#*.}${VERSION_POSTPEND} + echo "Version is: ${vrchat_sdk_version}" + echo "vrchat_sdk_version=$vrchat_sdk_version" >> $GITHUB_ENV + + - name: Generate SDK Client + run: bash ./generate.sh "${ARTIFACT_NAME}" + - name: Deploy SDK back into main branch and make tag uses: JamesIves/github-pages-deploy-action@v4 with: branch: main folder: . - commit-message: "Upgrade Java SDK to spec ${{ env.spec_version }}" - tag: ${{ env.spec_version }} + commit-message: "Upgrade Java SDK to spec ${vrchat_sdk_version}" + tag: ${vrchat_sdk_version} # gradle: # runs-on: ubuntu-latest diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9d9b3b16..f8a0e1ab 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,9 +19,9 @@ jobs: matrix: java: [ '8' ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up JDK - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} distribution: 'temurin' diff --git a/generate.sh b/generate.sh index 4a8cc547..dd5b7569 100755 --- a/generate.sh +++ b/generate.sh @@ -1,6 +1,10 @@ #!/bin/bash -npm install @openapitools/openapi-generator-cli +if [ ${#} -le 0 ] +then + echo "Usage: generate.sh " >&2 + exit 1 +fi rm docs -rf rm src/main/java/io/github/vrchatapi/*.java @@ -14,7 +18,7 @@ rm src/main/java/io/github/vrchatapi/model -rf --git-user-id=vrchatapi \ --git-repo-id=vrchatapi-java \ -o . \ --i https://raw.githubusercontent.com/vrchatapi/specification/gh-pages/openapi.yaml \ +-i "${1}" \ --http-user-agent="vrchatapi-java" # Remove unneccesary copy of spec