Skip to content

Commit 17896b0

Browse files
committed
wip: changes
1 parent c6f6794 commit 17896b0

File tree

7 files changed

+67
-44
lines changed

7 files changed

+67
-44
lines changed

.github/workflows/ci.yaml

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,64 @@
11
on:
22
repository_dispatch:
33
types: [release]
4+
workflow_dispatch:
5+
inputs:
6+
url:
7+
type: string
8+
description: URL (openapi.json)
49
push:
510
branches:
611
- main
712

813
name: Build & release
914

1015
jobs:
11-
build-and-release:
16+
build_and_release:
1217
runs-on: ubuntu-latest
13-
name: Release
1418
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v4
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/cache@v4
22+
with:
23+
key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
24+
restore-keys: pnpm-
25+
path: |
26+
~/.pnpm-store
27+
~/.cache/pnpm
28+
**/node_modules
1729
1830
- uses: pnpm/action-setup@v4
19-
name: Install pnpm
2031
with:
2132
version: 10
2233
run_install: false
2334

24-
- name: Install Node.js
25-
uses: actions/setup-node@v4
26-
with:
27-
node-version: 20
28-
cache: 'pnpm'
35+
- run: pnpm install
2936

30-
- name: Install dependencies
31-
run: pnpm install
32-
33-
- name: Download specification
34-
run: curl -L -o openapi.yaml https://vrchat.community/openapi.yaml
37+
- if: github.event_name == 'repository_dispatch'
38+
run: |
39+
curl -fo openapi.json ${{ github.event.client_payload.artifacts['openapi.json'] }}
40+
echo "from=repository_dispatch" >> $GITHUB_ENV
3541
36-
- name: Update version
42+
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.url != ''
3743
run: |
38-
version=$(yq '.info.version' openapi.yaml | tr -d '"')
39-
# pnpm version "${VERSION}-next.$(date +%s)" --no-git-tag-version
44+
curl -fo openapi.json ${{ github.event.inputs.url }}
45+
echo "from=workflow_dispatch" >> $GITHUB_ENV
46+
47+
- if: env.from == ''
48+
run: curl -fo openapi.json https://github.com/vrchatapi/specification/releases/latest/download/openapi.json
4049

41-
major=$(echo $version | cut -d. -f1)
42-
minor=$(echo $version | cut -d. -f2)
43-
patch=$(echo $version | cut -d. -f3)
50+
- run: |
51+
version=$(jq -r '.info.version' ./openapi.json)
52+
version_tag=$(node -p "require('semver').parse('$version')?.prerelease[0] || 'latest'")
4453
45-
version="$((major+1)).$minor.$patch"
54+
echo "version=$version" >> $GITHUB_ENV
55+
echo "version_tag=$version_tag" >> $GITHUB_ENV
4656
4757
pnpm version $version --no-git-tag-version
4858
49-
- name: Build
50-
run: pnpm build
59+
- run: pnpm build
5160

52-
- name: Release
61+
- if: github.ref == 'refs/heads/main'
5362
run: |
54-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
55-
pnpm publish --no-git-checks
56-
env:
57-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
63+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
64+
pnpm publish --no-git-checks --tag ${{ env.version_tag }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
src/generated
33
dist
4+
openapi.json
45
openapi.yaml

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "example",
33
"version": "1.0.0",
4+
"private": true,
45
"description": "",
56
"author": "",
67
"license": "ISC",

openapi-ts.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ import { defineConfig } from "@hey-api/openapi-ts";
33
import { errorPlugin } from "./plugins/error";
44

55
export default defineConfig({
6-
input: "./openapi.yaml",
6+
input: "./openapi.json",
77
output: "src/generated",
88
plugins: [
99
{
1010
name: "@hey-api/typescript",
1111
exportFromIndex: false,
1212
requests: "{{name}}",
13-
enums: {
14-
case: "camelCase"
15-
}
13+
// todo: enable after generator doesn't create conflicting names.
14+
// todo: see: https://discord.com/channels/@me/1414524675156869140/1446935685780209664
15+
// enums: {
16+
// case: "camelCase"
17+
// }
1618
},
1719
{
1820
name: "@hey-api/client-fetch",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
"@types/node": "^24.10.1",
5050
"bun-plugin-dts": "^0.3.0",
5151
"eslint": "^9.39.1",
52+
"semver": "^7.7.3",
5253
"tsup": "^8.5.1",
5354
"typed-emitter": "^2.1.0",
5455
"typescript": "^5.9.3"
5556
}
56-
}
57+
}

plugins/error.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const errorPlugin = definePluginConfig({
44
name: "vrchat/error",
55
config: {},
66
dependencies: ["@hey-api/typescript"],
7+
// @ts-expect-error: we're using an experimental version of the generator.
78
handler: ({ plugin }) => {
89
const symbol = plugin.querySymbol({ resourceId: "#/components/schemas/Error" });
910

pnpm-lock.yaml

Lines changed: 20 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)