From c67ee1731c79014a9c58ce4c6d24340a9d9ab642 Mon Sep 17 00:00:00 2001 From: zhanghengxin <812718649@qq.com> Date: Mon, 22 May 2023 16:45:06 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Introducing=20new=20features.Incor?= =?UTF-8?q?porating=20automatic=20publishin=E2=80=A6=20(#1107)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introducing new features.Incorporating automatic publishing for the openAPI npm package. --- .github/workflows/publish_npm.yaml | 38 ++++++++++++++++++++++++++++++ package.json | 38 ++++++++++++++++++++++++++++++ tsconfig.json | 25 ++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 .github/workflows/publish_npm.yaml create mode 100644 package.json create mode 100644 tsconfig.json diff --git a/.github/workflows/publish_npm.yaml b/.github/workflows/publish_npm.yaml new file mode 100644 index 0000000..de4c139 --- /dev/null +++ b/.github/workflows/publish_npm.yaml @@ -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}} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b0ba851 --- /dev/null +++ b/package.json @@ -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" +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..89d3573 --- /dev/null +++ b/tsconfig.json @@ -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" +} \ No newline at end of file