Introducing new features.Incorporating automatic publishin… (#1107)

Introducing new features.Incorporating automatic publishing for the
openAPI npm package.
This commit is contained in:
zhanghengxin 2023-05-22 16:45:06 +08:00 committed by GitHub
parent eaca399ef9
commit c67ee1731c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 101 additions and 0 deletions

38
.github/workflows/publish_npm.yaml vendored Normal file
View file

@ -0,0 +1,38 @@
name: publish npm
on:
push:
tags:
- v*.*.*
workflow_dispatch:
permissions:
contents: write
jobs:
publish-npm:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Set version
run: |
sudo apt-get install jq
jq '.version="${{ steps.get_version.outputs.VERSION }}"' package.json > package.json.new
mv package.json.new package.json
- name: Generate SDK
run: |
npm cache clean --force
npm install @openapitools/openapi-generator-cli -g
make build
- run: npm i
- run: npm run start
- run: npm publish -W
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

38
package.json Normal file
View file

@ -0,0 +1,38 @@
{
"name": "@icewhale/casaos-openapi",
"version": "0.0.1",
"scripts": {
"clean": "rm -rf generate",
"build": "rm -rf dist && tsc && yarn clean",
"generate:local": "openapi-generator-cli generate -g typescript-axios -i ./api/casaos/openapi.yaml -o ./generate",
"generate:npx": "npx @openapitools/openapi-generator-cli generate -g typescript-axios -i ./api/casaos/openapi.yaml -o ./generate",
"generate:ts": "npx openapi-typescript-codegen --input ./api/casaos/openapi.yaml --output ./generate",
"start": "yarn generate:local && yarn build"
},
"homepage": "https://github.com/IceWhaleTech/CasaOS#readme",
"description": "Casaos Typescript+Axios SDK",
"keywords": [
"CasaOS",
"SDK",
"CasaOS Axios"
],
"main": "dist/index.js",
"files": [
"LICENSE",
"README.md",
"dist",
"generate"
],
"dependencies": {
"axios": "^1.1.0"
},
"devDependencies": {
"all-contributors-cli": "^6.24.0",
"@openapitools/openapi-generator-cli": "2.5.2",
"@types/node": "^18.8.3",
"openapi-typescript-codegen": "^0.23.0",
"typescript": "^4.9.5"
},
"author": "casaos",
"license": "Apache-2.0"
}

25
tsconfig.json Normal file
View file

@ -0,0 +1,25 @@
{
"compilerOptions": {
"declaration": true,
"lib": [
"es2017",
"DOM"
],
"module": "commonjs",
"target": "es6",
"skipLibCheck": true,
"sourceMap": false,
"strict": true,
"useUnknownInCatchVariables": false,
"resolveJsonModule": true,
"esModuleInterop": true,
"outDir": "dist",
"types": [
"node"
],
},
"exclude": [
"node_modules"
],
"main": "generate/index"
}