Modernize CI #239
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| push: | |
| branches: | |
| - '**' | |
| pull_request: | |
| repository_dispatch: | |
| types: [release] | |
| workflow_dispatch: | |
| inputs: | |
| url: | |
| type: string | |
| description: URL (openapi.json) | |
| workflow_call: | |
| inputs: | |
| ref: | |
| description: Ref of this repository to build. | |
| required: false | |
| type: string | |
| default: main | |
| permissions: | |
| id-token: write | |
| contents: read | |
| name: CI | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| tag: ${{ steps.version.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| repository: vrchatapi/vrchatapi-javascript | |
| ref: ${{ inputs.ref || github.ref }} | |
| - uses: vrchatapi/specification/.github/actions/download@main | |
| with: | |
| url: ${{ inputs.url }} | |
| - uses: pnpm/setup@v2 | |
| with: | |
| runtime: node@24 | |
| cache: true | |
| - run: pnpm generate | |
| - id: version | |
| run: | | |
| version=$(jq -r '.info.version' ./openapi.json) | |
| version=$(node -p " | |
| const semver = require('semver'); | |
| const version = semver.parse('$version'); | |
| version.major += 1; | |
| version.minor += 2; | |
| version.format(); | |
| ") | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "tag=$(node -p "require('semver').parse('$version')?.prerelease[0] || 'latest'")" >> $GITHUB_OUTPUT | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: javascript-generated | |
| path: src/generated | |
| build: | |
| needs: generate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| repository: vrchatapi/vrchatapi-javascript | |
| ref: ${{ inputs.ref || github.ref }} | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: javascript-generated | |
| path: src/generated | |
| - uses: pnpm/setup@v2 | |
| with: | |
| runtime: node@24 | |
| cache: true | |
| - run: pnpm version ${{ needs.generate.outputs.version }} --no-git-tag-version | |
| - run: pnpm build | |
| - if: github.event_name == 'pull_request' || github.repository == 'vrchatapi/vrchatapi-javascript' | |
| run: | | |
| pnpm exec pkg-pr-new publish \ | |
| --packageManager=pnpm \ | |
| --no-template \ | |
| --no-compact \ | |
| --commentWithSha | |
| - run: pnpm pack --out package.tgz | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: javascript-package | |
| path: package.tgz | |
| publish: | |
| needs: | |
| - generate | |
| - build | |
| if: github.repository == 'vrchatapi/vrchatapi-javascript' | |
| && github.ref == 'refs/heads/main' | |
| && !contains(github.event.head_commit.message, 'no_release') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: javascript-package | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| - run: npm publish package.tgz --tag ${{ needs.generate.outputs.tag }} |