45 lines
1.3 KiB
Bash
Executable File
45 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
VERSION=0.1.0
|
|
|
|
# Navigate to project root
|
|
cd "$(dirname "$0")/backend" || exit
|
|
|
|
# Generate OpenAPI JSON file
|
|
python3 main.py generate-openapi
|
|
if [[ ! -f openapi.json ]]; then
|
|
echo "Error: openapi.json file not generated!"
|
|
exit 1
|
|
fi
|
|
|
|
# Download OpenAPI generator CLI if not present
|
|
OPENAPI_VERSION=7.8.0
|
|
if [[ ! -f openapi-generator-cli.jar ]]; then
|
|
wget "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${OPENAPI_VERSION}/openapi-generator-cli-${OPENAPI_VERSION}.jar" -O openapi-generator-cli.jar
|
|
fi
|
|
|
|
# Run OpenAPI generator
|
|
java -jar openapi-generator-cli.jar generate \
|
|
-i "$(pwd)/openapi.json" \
|
|
-o python-client/ \
|
|
-g python \
|
|
--additional-properties=packageName=aareDBclient,projectName=aareDB,packageVersion=${VERSION}
|
|
|
|
# Check if the generator succeeded
|
|
if [[ ! -d python-client ]]; then
|
|
echo "OpenAPI generator failed. Exiting."
|
|
exit 1
|
|
fi
|
|
|
|
# Build Python package
|
|
cd python-client || exit
|
|
python3 -m venv .venv
|
|
source .venv/bin/activate
|
|
pip install -U pip twine build
|
|
python -m build
|
|
|
|
# Upload package (only if in CI environment)
|
|
if [[ -z "${CI_API_V4_URL}" || -z "${CI_PROJECT_ID}" ]]; then
|
|
echo "Skipping package upload—CI variables not set."
|
|
else
|
|
twine upload --repository-url "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi" dist/*
|
|
fi |