From 99adf1222424690512854cdc3a16fab44e44b607 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 11 Dec 2024 10:22:59 +0100 Subject: [PATCH] feat: add support for typescript-fetch SDK and update typescript-angular configuration (#1556) * feat: add support for typescript-fetch SDK and update typescript-angular configuration * correct the sdk name * handle extra spaces --- .../openapi/typescript-angular-config.json | 2 +- .github/openapi/typescript-fetch-config.json | 5 ++++ .github/workflows/release-and-publish-sdk.yml | 26 +++++++++++-------- 3 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 .github/openapi/typescript-fetch-config.json diff --git a/.github/openapi/typescript-angular-config.json b/.github/openapi/typescript-angular-config.json index fc279bbcf..6da9d03d6 100644 --- a/.github/openapi/typescript-angular-config.json +++ b/.github/openapi/typescript-angular-config.json @@ -1,6 +1,6 @@ { "generatorName": "typescript-angular", - "npmName": "@scicatproject/scicat-sdk-ts", + "npmName": "@scicatproject/scicat-sdk-ts-angular", "ngVersion": "16.2.12", "withInterfaces": true } diff --git a/.github/openapi/typescript-fetch-config.json b/.github/openapi/typescript-fetch-config.json new file mode 100644 index 000000000..2b2c3ae1a --- /dev/null +++ b/.github/openapi/typescript-fetch-config.json @@ -0,0 +1,5 @@ +{ + "generatorName": "typescript-fetch", + "npmName": "@scicatproject/scicat-sdk-ts-fetch", + "supportsES6": true +} diff --git a/.github/workflows/release-and-publish-sdk.yml b/.github/workflows/release-and-publish-sdk.yml index 0192da59e..f7c890150 100644 --- a/.github/workflows/release-and-publish-sdk.yml +++ b/.github/workflows/release-and-publish-sdk.yml @@ -152,11 +152,9 @@ jobs: --git-repo-id scicat-backend-next \ --git-user-id SciCatProject \ -o ./sdk/${{ matrix.generator }} $( - if [ "${{ matrix.generator }}" == "typescript-angular" ]; then + if [ "${{ matrix.generator }}" == "typescript-angular" ] || [ "${{ matrix.generator }}" == "typescript-fetch" ]; then echo "--additional-properties=npmVersion=${{ needs.build-release.outputs.new_tag}}"; - elif [ "${{ matrix.generator }}" == "python" ]; then - echo "--additional-properties=packageVersion=${{ needs.build-release.outputs.new_tag}}"; - elif [ "${{ matrix.generator }}" == "python-pydantic-v1" ]; then + elif [ "${{ matrix.generator }}" == "python" ] || [ "${{ matrix.generator }}" == "python-pydantic-v1" ]; then echo "--additional-properties=packageVersion=${{ needs.build-release.outputs.new_tag}}"; fi ) @@ -169,9 +167,12 @@ jobs: npm-publish: needs: generate-upload-sdk runs-on: ubuntu-latest + strategy: + matrix: + sdk_type: [typescript-angular, typescript-fetch] environment: - name: npm-sdk-package - url: https://www.npmjs.com/package/@scicatproject/scicat-sdk-ts + name: ${{ matrix.sdk_type }}-sdk-package + url: ${{ matrix.sdk_type == 'typescript-angular' && 'https://www.npmjs.com/package/@scicatproject/scicat-sdk-ts-angular' || 'https://www.npmjs.com/package/@scicatproject/scicat-sdk-ts-fetch' }} steps: - name: Checkout repository @@ -183,19 +184,22 @@ jobs: node-version: ${{ env.NODE_VERSION }} registry-url: "https://registry.npmjs.org/" - - name: Download TypeScript Angular SDK Artifact + - name: Download TypeScript SDK Artifact uses: actions/download-artifact@v4 with: - name: sdk-typescript-angular-${{github.sha}} + name: sdk-${{ matrix.sdk_type }}-${{ github.sha }} path: ./sdk - name: Publish package run: | npm install npm run build - cd dist + if [ "${{ matrix.sdk_type }}" == "typescript-angular" ]; then + # publish dist folder for typescript-angular + cd dist + fi npm publish --access public - working-directory: ./sdk/typescript-angular/ + working-directory: ./sdk/${{ matrix.sdk_type }}/ env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -223,7 +227,7 @@ jobs: - name: Download Python SDK Artifact uses: actions/download-artifact@v4 with: - name: sdk-${{ matrix.sdk_type }}-${{github.sha}} + name: sdk-${{ matrix.sdk_type }}-${{ github.sha }} path: ./sdk - name: Install dependencies