-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: added sdk generate & publish github workflow
- Loading branch information
1 parent
3e4dc8b
commit 27d0618
Showing
4 changed files
with
146 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: Generate and Publish SDK for multiple languages | ||
|
||
on: | ||
push: | ||
branches: | ||
- release | ||
|
||
env: | ||
NODE_VERSION: 18.x | ||
|
||
jobs: | ||
generate-sdk: | ||
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: Run docker-compose | ||
run: | | ||
cp CI/ESS/e2e/docker-compose.e2e.yaml docker-compose.yaml | ||
docker compose pull | ||
docker compose build --no-cache | ||
docker compose up -d | ||
- name: Wait for Backend | ||
run: | | ||
npm install -g wait-on | ||
wait-on http://localhost:3000/api/v3/health --timeout 200000 | ||
- name: Run SDK generation script | ||
run: ./scripts/generate-sdk-local.sh | ||
|
||
- name: Fix permissions for SDK directory | ||
run: sudo chown -R $USER:$USER ./sdk | ||
|
||
- name: Upload generated SDK JSON | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: sdk | ||
path: ./sdk | ||
|
||
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: | ||
node-version: ${{ env.NODE_VERSION }} | ||
registry-url: "https://registry.npmjs.org/" | ||
|
||
- 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: generate-sdk | ||
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 | ||
|
||
- name: Download generated SDK | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: sdk | ||
path: ./sdk/ | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
|
||
- 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 distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: ./sdk/python/dist/ |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Download the Swagger schema | ||
curl -o ./swagger-schema.json http://localhost:3000/explorer-json | ||
|
||
# Remove the existing SDK directory if it exists | ||
rm -rf ./sdk | ||
|
||
docker run \ | ||
--rm \ | ||
-v "${PWD}":/local \ | ||
openapitools/openapi-generator-cli generate \ | ||
-c /local/scripts/typescript-sdk.json \ | ||
|
||
docker run \ | ||
--rm \ | ||
-v "${PWD}":/local \ | ||
openapitools/openapi-generator-cli generate \ | ||
-c /local/scripts/python-sdk.json \ | ||
|
||
# Remove the Swagger schema file | ||
rm ./swagger-schema.json |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"packageName": "Scicat-Python-SDK", | ||
"projectName": "Scicat-Python-SDK", | ||
"packageVerion": "0.0.1", | ||
"inputSpec": "/local/swagger-schema.json", | ||
"generatorName": "python", | ||
"outputDir": "/local/sdk/python" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"npmName": "@scicat-sdk/typescript-angular", | ||
"npmVersion": "0.0.7", | ||
"ngVersion": "16.2.12", | ||
"withInterfaces": true, | ||
"inputSpec": "/local/swagger-schema.json", | ||
"generatorName": "typescript-angular", | ||
"outputDir": "/local/sdk/typescript" | ||
} |