tentative to add ci pipeline
This commit is contained in:
@ -1,23 +1,45 @@
|
||||
#!/bin/bash
|
||||
VERSION={0.1.0}
|
||||
VERSION=0.1.0
|
||||
|
||||
# Run whataver you need to generate FastAPI .json file
|
||||
pushd backend
|
||||
python -m main generate-openapi
|
||||
popd
|
||||
# Navigate to project root
|
||||
cd "$(dirname "$0")/backend" || exit
|
||||
|
||||
# Download OpenAPI generator
|
||||
# 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
|
||||
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${OPENAPI_VERSION}/openapi-generator-cli-${OPENAPI_VERSION}.jar -O openapi-generator-cli.jar
|
||||
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 (requires java to be installed - this is already configured on mx-aare-test)
|
||||
java -jar openapi-generator-cli.jar generate -i /backend/openapi.json -o python-client/ -g python --additional-properties=packageName=aare-test,packageVersion=${VERSION}
|
||||
# build python package
|
||||
cd python-client
|
||||
python3.11 -m venv .venv
|
||||
# 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 twine build
|
||||
pip install -U pip twine build
|
||||
python -m build
|
||||
|
||||
# upload the package into the package repository - this uses variables from CI pipeline, so it won't work offline
|
||||
twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
|
||||
# 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
|
Reference in New Issue
Block a user