From d5b39bd29e834928aa197ca42954b61c72a2f0d1 Mon Sep 17 00:00:00 2001 From: Tejas Mehta Date: Thu, 29 Aug 2024 12:57:13 -0400 Subject: [PATCH] Add auto sdk gen + release upload action (#86) --- .github/workflows/create-sdk-on-release.yml | 32 +++++++++++++ .gitignore | 1 + openapitools.json | 7 +++ package.json | 2 + packages/api-gateway/.gitignore | 5 +- yarn.lock | 53 +++++++++++++++++++++ 6 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/create-sdk-on-release.yml create mode 100644 openapitools.json diff --git a/.github/workflows/create-sdk-on-release.yml b/.github/workflows/create-sdk-on-release.yml new file mode 100644 index 00000000..e71dc2d9 --- /dev/null +++ b/.github/workflows/create-sdk-on-release.yml @@ -0,0 +1,32 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Upload SDK for Release + +jobs: + build: + name: Upload SDK for Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Setup Node + uses: actions/setup-node@v4 + - name: Install Yarn + run: npm install -g yarn + - name: Install Dependencies + run: yarn install + - name: Generate SDK + run: yarn gen-client-sdk + - name: Create Tarball + run: tar -czf juno-client-sdk.tar.gz juno-client-sdk + - name: Release with Notes + uses: softprops/action-gh-release@v1 + with: + files: | + juno-client-sdk.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 19582ff3..3b543661 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ lerna-debug.log* .env .env.local .bitwarden.env +juno-client-sdk/ diff --git a/openapitools.json b/openapitools.json new file mode 100644 index 00000000..2f4612ce --- /dev/null +++ b/openapitools.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", + "spaces": 2, + "generator-cli": { + "version": "7.8.0" + } +} diff --git a/package.json b/package.json index cd798376..184b863e 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lint": "nx run-many --target=lint --no-cloud", "sync-protos": "node syncJunoProtos.js", "gen-proto": "yarn workspace juno-proto install && yarn workspace juno-proto build && yarn sync-protos", + "gen-client-sdk": "yarn openapi-generator-cli generate -g typescript-node -i ./packages/api-gateway/sdk.yaml -o ./juno-client-sdk", "preinstall": "yarn gen-proto", "test:e2e:api-gateway-live": "GATEWAY_COMMAND=test:e2e:watch RUN_MODE=test yarn start:dev:live-all --exit-code-from api-gateway", "test:e2e:auth-service-live": "AUTH_COMMAND=test:e2e:watch RUN_MODE=test yarn start:dev:live-all --exit-code-from auth-service auth-service", @@ -34,6 +35,7 @@ "test:e2e:logging-service": "LOGGING_COMMAND=test:e2e RUN_MODE=test yarn start:dev --exit-code-from logging-service logging-service" }, "devDependencies": { + "@openapitools/openapi-generator-cli": "^2.13.5", "concurrently": "^8.2.2", "nx": "^17.0.0", "prettier": "^3.0.3", diff --git a/packages/api-gateway/.gitignore b/packages/api-gateway/.gitignore index 22f55adc..4c5d9abf 100644 --- a/packages/api-gateway/.gitignore +++ b/packages/api-gateway/.gitignore @@ -32,4 +32,7 @@ lerna-debug.log* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json -!.vscode/extensions.json \ No newline at end of file +!.vscode/extensions.json + +sdk/ +sdk* diff --git a/yarn.lock b/yarn.lock index 81b80634..6e57fe4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -736,6 +736,11 @@ resolved "https://registry.yarnpkg.com/@nestjs/axios/-/axios-3.0.1.tgz#b006f81dd54a49def92cfaf9a8970434567e75ce" integrity sha512-VlOZhAGDmOoFdsmewn8AyClAdGpKXQQaY1+3PGB+g6ceurGIdTxZgRX3VXc1T6Zs60PedWjg3A82TDOB05mrzQ== +"@nestjs/axios@3.0.2": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@nestjs/axios/-/axios-3.0.2.tgz#0078c101a29fb46f5c566d68a4315fddabc083ed" + integrity sha512-Z6GuOUdNQjP7FX+OuV2Ybyamse+/e0BFdTWBX5JxpBDKA+YkdLynDgG6HTF04zy6e9zPa19UX0WA2VDoehwhXQ== + "@nestjs/cli@^10.0.0": version "10.3.2" resolved "https://registry.yarnpkg.com/@nestjs/cli/-/cli-10.3.2.tgz#42d2764ead6633e278c55d42de871b4cc1db002b" @@ -981,6 +986,30 @@ rxjs "7.8.1" tslib "2.6.2" +"@openapitools/openapi-generator-cli@^2.13.5": + version "2.13.5" + resolved "https://registry.yarnpkg.com/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.13.5.tgz#6fc835e18bce9c84be268264fcfa37456ef46025" + integrity sha512-9VgeKOTiiatKSwZDKKB3C86cW8tN9eDcFohotD4eisdK38UQswk/4Ysoq9KChRCbymjoMp6AIDHPtK1DQ2fTgw== + dependencies: + "@nestjs/axios" "3.0.2" + "@nestjs/common" "10.3.0" + "@nestjs/core" "10.3.0" + "@nuxtjs/opencollective" "0.3.2" + axios "1.7.4" + chalk "4.1.2" + commander "8.3.0" + compare-versions "4.1.4" + concurrently "6.5.1" + console.table "0.10.0" + fs-extra "10.1.0" + glob "7.2.3" + https-proxy-agent "7.0.4" + inquirer "8.2.6" + lodash "4.17.21" + reflect-metadata "0.1.13" + rxjs "7.8.1" + tslib "2.6.2" + "@pkgjs/parseargs@^0.11.0": version "0.11.0" resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" @@ -1673,6 +1702,13 @@ agent-base@6: dependencies: debug "4" +agent-base@^7.0.2: + version "7.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" + integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== + dependencies: + debug "^4.3.4" + ajv-formats@2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" @@ -1828,6 +1864,15 @@ axios@1.6.5: form-data "^4.0.0" proxy-from-env "^1.1.0" +axios@1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2" + integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + axios@^1.6.0, axios@^1.6.4, axios@^1.6.7: version "1.6.8" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.8.tgz#66d294951f5d988a00e87a0ffb955316a619ea66" @@ -3349,6 +3394,14 @@ http-errors@2.0.0: statuses "2.0.1" toidentifier "1.0.1" +https-proxy-agent@7.0.4: + version "7.0.4" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz#8e97b841a029ad8ddc8731f26595bad868cb4168" + integrity sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg== + dependencies: + agent-base "^7.0.2" + debug "4" + https-proxy-agent@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6"