This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate and Publish SDK for multiple languages | |
on: | |
# release: | |
# types: | |
# - created | |
push: | |
branches: | |
- main | |
env: | |
NODE_VERSION: 18.x | |
jobs: | |
start-backend-and-upload-swagger-schema: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{env.NODE_VERSION}} | |
- name: get-npm-version | |
id: package-version | |
uses: martinbeentjes/[email protected] | |
- name: Pull MongoDB Image | |
run: | | |
docker pull mongo:latest | |
docker run -d --name mongo-container -p 27017:27017 mongo:latest | |
- name: Install Backend and wait for it to be ready | |
env: | |
MONGODB_URI: "mongodb://localhost:27017/scicat" | |
JWT_SECRET: thisIsTheJwtSecret | |
run: | | |
npm install -g wait-on && npm install | |
npm run start & wait-on http://localhost:3000/api/v3/health --timeout 200000 | |
- name: Download the Swagger schema | |
run: curl -o ./swagger-schema.json http://localhost:3000/explorer-json | |
- name: Update SDK Version for each language in Config Files | |
run: node scripts/update-sdk-versions.js | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: swagger-schema | |
path: ./swagger-schema.json | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: updated-configs | |
path: .github/openapi/ | |
generate-and-upload-sdk: | |
runs-on: ubuntu-latest | |
needs: start-backend-and-upload-swagger-schema | |
strategy: | |
matrix: | |
generator: [python, typescript] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: swagger-schema | |
path: . | |
- uses: actions/download-artifact@v4 | |
with: | |
name: updated-configs | |
path: .github/openapi/ | |
- name: hello | |
run: | | |
echo " npm version: ${{ needs.start-backend-and-upload-swagger-schema.get-npm-version.outputs.current-version}} " | |
# - name: Generate Client | |
# uses: openapi-generators/openapitools-generator-action@v1 | |
# with: | |
# generator: ${{ matrix.generator }} | |
# openapi-file: ./swagger-schema.json | |
# config-file: .github/openapi/${{ matrix.generator }}-config.json | |
# command-args: -o ./sdk/${{ matrix.generator }} | |
# - uses: actions/upload-artifact@v4 | |
# with: | |
# name: sdk-${{ matrix.generator }} | |
# path: ./sdk | |
# npm-publish: | |
# needs: generate-and-upload-sdk | |
# runs-on: ubuntu-latest | |
# environment: | |
# name: npm-sdk-package | |
# url: https://www.npmjs.com/package/@scicat-sdk/typescript-angular | |
# steps: | |
# - name: Checkout repository | |
# uses: actions/checkout@v4 | |
# - name: Set up Node.js | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: ${{ env.NODE_VERSION }} | |
# registry-url: "https://registry.npmjs.org/" | |
# - uses: actions/download-artifact@v4 | |
# with: | |
# name: sdk-typescript | |
# path: ./sdk | |
# - name: Publish package | |
# run: | | |
# npm install | |
# npm run build | |
# npm publish --access public | |
# working-directory: ./sdk/typescript/ | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# pypi-publish: | |
# needs: generate-and-upload-sdk | |
# runs-on: ubuntu-latest | |
# environment: | |
# name: pypi-sdk-package | |
# url: https://pypi.org/p/Scicat-Python-SDK | |
# permissions: | |
# id-token: write | |
# steps: | |
# - name: Checkout repository | |
# uses: actions/checkout@v4 | |
# - name: Set up Python | |
# uses: actions/setup-python@v4 | |
# with: | |
# python-version: ${{ env.PYTHON_VERSION }} | |
# - uses: actions/download-artifact@v4 | |
# with: | |
# name: sdk-python | |
# path: ./sdk | |
# - name: Install dependencies | |
# run: | | |
# python -m pip install --upgrade pip | |
# pip install setuptools wheel | |
# working-directory: ./sdk/python/ | |
# - name: Build package | |
# run: | | |
# python setup.py sdist bdist_wheel | |
# working-directory: ./sdk/python/ | |
# - name: Publish package | |
# uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# packages-dir: ./sdk/python/dist/ |