Sync project metadata with pyproject.toml
Updated scripts and backend to dynamically retrieve project name and version from `pyproject.toml`. This ensures consistent metadata across the OpenAPI client generation and the FastAPI application.
This commit is contained in:
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
VERSION=0.1.0
|
||||
|
||||
# Extract values from pyproject.toml
|
||||
PYPROJECT_FILE="$(dirname "$0")/../pyproject.toml"
|
||||
|
||||
VERSION=$(grep -Po '(?<=version = ")[^"]*' "$PYPROJECT_FILE")
|
||||
NAME=$(grep -Po '(?<=name = ")[^"]*' "$PYPROJECT_FILE")
|
||||
|
||||
if [[ -z "$VERSION" || -z "$NAME" ]]; then
|
||||
echo "Error: Could not determine version or name from pyproject.toml"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Using project name: $NAME"
|
||||
echo "Using version: $VERSION"
|
||||
|
||||
# Navigate to project root
|
||||
cd "$(dirname "$0")/backend" || exit
|
||||
@ -17,12 +30,12 @@ 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
|
||||
# Run OpenAPI generator with synced name and version
|
||||
java -jar openapi-generator-cli.jar generate \
|
||||
-i "$(pwd)/openapi.json" \
|
||||
-o python-client/ \
|
||||
-g python \
|
||||
--additional-properties=packageName=aareDBclient,projectName=aareDB,packageVersion=${VERSION}
|
||||
--additional-properties=packageName="${NAME}client",projectName="${NAME}",packageVersion="${VERSION}"
|
||||
|
||||
# Check if the generator succeeded
|
||||
if [[ ! -d python-client ]]; then
|
||||
@ -38,5 +51,4 @@ pip install -U pip build
|
||||
python -m build
|
||||
|
||||
# Skip uploading the package. This will happen in the release stage.
|
||||
echo "Python client generated and package built successfully."
|
||||
echo "git.psi.ch pushed"
|
||||
echo "Python client generated and package built successfully."
|
Reference in New Issue
Block a user