-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (41 loc) · 1.63 KB
/
Copy pathclient-build.yml
File metadata and controls
43 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
name: DevState Client (TS) Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-client:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install generator
run: |
npm -C clients/typescript install --no-audit --no-fund
npm -C clients/typescript install axios
- name: Generate TS client from OpenAPI
run: |
npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g typescript-axios -o clients/typescript/src --additional-properties=supportsES6=true,withSeparateModelsAndApi=true,modelPropertyNaming=original --api-package apis --model-package models
- name: Bump client version if OpenAPI changed
id: bump
run: |
if git diff --name-only HEAD^ HEAD | grep -q 'openapi.yaml'; then
echo 'OpenAPI changed; bump minor version'
node -e "const fs=require('fs');const p='./clients/typescript/package.json';const j=JSON.parse(fs.readFileSync(p));const [maj,min,patch]=String(j.version||'0.1.0').split('.').map(Number);j.version=[maj,min+1,0].join('.');fs.writeFileSync(p,JSON.stringify(j,null,2));"
else
echo 'No OpenAPI change';
fi
- name: Build
run: |
npm -C clients/typescript run build
- name: Pack CommonJS client
run: |
cd clients/typescript && npm pack
- name: Upload client artifact
uses: actions/upload-artifact@v4
with:
name: devstate-client-ts
path: clients/typescript/dist