Skip to content

Modernize CI

Modernize CI #228

Workflow file for this run

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@ci/modernise-actions
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: generated-javascript
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: generated-javascript
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
- run: |
pnpm exec pkg-pr-new publish \
--packageManager=pnpm \
--no-template \
--no-compact \
--commentWithSha
publish:
needs:
- generate
- build
if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'no_release')
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: generated-javascript
path: src/generated
- uses: pnpm/setup@v2
with:
runtime: node@24
cache: true
- uses: actions/setup-node@v7
with:
node-version: 24
registry-url: https://registry.npmjs.org
# Trusted publishing requires npm CLI version 11.5.1 or later.
# https://docs.npmjs.com/trusted-publishers
- run: npm install -g npm@latest
- run: pnpm version ${{ needs.generate.outputs.version }} --no-git-tag-version
- run: pnpm build
- run: pnpm publish --no-git-checks --tag ${{ needs.generate.outputs.tag }}