Build & release #150
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: | |
| repository_dispatch: | |
| types: [release] | |
| workflow_dispatch: | |
| inputs: | |
| url: | |
| type: string | |
| description: URL (openapi.json) | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read | |
| name: Build & release | |
| jobs: | |
| build_and_release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'pnpm' | |
| - run: npm install -g npm@latest | |
| - run: pnpm install | |
| - if: github.event_name == 'repository_dispatch' | |
| run: | | |
| curl -Lfo openapi.json ${{ github.event.client_payload.artifacts['openapi.json'] }} | |
| echo "from=repository_dispatch" >> $GITHUB_ENV | |
| - if: github.event_name == 'workflow_dispatch' && github.event.inputs.url != '' | |
| run: | | |
| curl -Lfo openapi.json ${{ github.event.inputs.url }} | |
| echo "from=workflow_dispatch" >> $GITHUB_ENV | |
| - if: env.from == '' | |
| run: curl -Lfo openapi.json https://github.com/vrchatapi/specification/releases/latest/download/openapi.json | |
| - run: | | |
| version=$(jq -r '.info.version' ./openapi.json) | |
| version=$(node -p " | |
| const semver = require('semver'); | |
| const version = semver.parse('$version'); | |
| version.major += 1; | |
| version.format() | |
| ") | |
| version_tag=$(node -p "require('semver').parse('$version')?.prerelease[0] || 'latest'") | |
| echo "version=$version" >> $GITHUB_ENV | |
| echo "version_tag=$version_tag" >> $GITHUB_ENV | |
| pnpm version $version --no-git-tag-version | |
| - run: pnpm build | |
| - if: github.ref == 'refs/heads/main' | |
| run: pnpm publish --no-git-checks --tag ${{ env.version_tag }} |