-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0631a7
commit 9a2aefa
Showing
1 changed file
with
69 additions
and
124 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
name: Generate and Publish SDK for multiple languages | ||
|
||
on: | ||
# release: | ||
# types: | ||
# - created | ||
release: | ||
types: | ||
- created | ||
push: | ||
branches: | ||
- main | ||
|
@@ -12,7 +12,7 @@ env: | |
NODE_VERSION: 18.x | ||
|
||
jobs: | ||
start-backend-and-upload-swagger-schema: | ||
spin-up-backend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
|
@@ -23,142 +23,87 @@ jobs: | |
with: | ||
node-version: ${{env.NODE_VERSION}} | ||
|
||
- name: get-npm-version | ||
id: package-version | ||
uses: martinbeentjes/[email protected] | ||
|
||
- name: Pull MongoDB Image | ||
- name: Run docker-compose | ||
run: | | ||
docker pull mongo:latest | ||
docker run -d --name mongo-container -p 27017:27017 mongo:latest | ||
cp CI/ESS/e2e/docker-compose.e2e.yaml docker-compose.yaml | ||
docker compose pull | ||
docker compose build --no-cache | ||
docker compose up -d | ||
- name: Install Backend and wait for it to be ready | ||
env: | ||
MONGODB_URI: "mongodb://localhost:27017/scicat" | ||
JWT_SECRET: thisIsTheJwtSecret | ||
- name: Wait for Backend | ||
run: | | ||
npm install -g wait-on && npm install | ||
npm run start & wait-on http://localhost:3000/api/v3/health --timeout 200000 | ||
npm install -g wait-on | ||
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: Run SDK generation script | ||
run: ./scripts/generate-sdk-local.sh | ||
|
||
- name: Update SDK Version for each language in Config Files | ||
run: node scripts/update-sdk-versions.js | ||
- name: Fix permissions for SDK directory | ||
run: sudo chown -R $USER:$USER ./sdk | ||
|
||
- uses: actions/upload-artifact@v4 | ||
- name: Upload generated SDK JSON | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: swagger-schema | ||
path: ./swagger-schema.json | ||
name: sdk | ||
path: ./sdk | ||
|
||
- uses: actions/upload-artifact@v4 | ||
npm-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
name: updated-configs | ||
path: .github/openapi/ | ||
node-version: ${{ env.NODE_VERSION }} | ||
registry-url: "https://registry.npmjs.org/" | ||
|
||
generate-and-upload-sdk: | ||
runs-on: ubuntu-latest | ||
needs: start-backend-and-upload-swagger-schema | ||
strategy: | ||
matrix: | ||
generator: [python, typescript] | ||
- name: Publish SDK to npm | ||
run: | | ||
npm install | ||
npm run build | ||
cd dist && npm publish --access public | ||
working-directory: ./sdk/typescript | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
pypi-publish: | ||
needs: spin-up-backend | ||
name: Publish packages to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/Scicat-Python-SDK | ||
permissions: | ||
id-token: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- uses: actions/download-artifact@v4 | ||
- name: Download generated SDK | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: swagger-schema | ||
path: . | ||
- uses: actions/download-artifact@v4 | ||
name: sdk | ||
path: ./sdk/ | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
name: updated-configs | ||
path: .github/openapi/ | ||
python-version: "3.x" | ||
|
||
- name: hello | ||
- name: Install dependencies | ||
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/ | ||
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 distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: ./sdk/python/dist/ |