fix(ci): follow redirects #144
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 | |
| name: Build & release | |
| jobs: | |
| build_and_release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/cache@v4 | |
| with: | |
| key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: pnpm- | |
| path: | | |
| ~/.pnpm-store | |
| ~/.cache/pnpm | |
| **/node_modules | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - 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_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: | | |
| echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
| pnpm publish --no-git-checks --tag ${{ env.version_tag }} |