11on :
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
813name : Build & release
914
1015jobs :
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 }}
0 commit comments