#!/bin/bash
set -e

# Change to the directory of the script
cd "$(dirname "$0")"

# Clean up previous builds
echo "Cleaning up dist/ and build/..."
rm -rf dist/ build/ *.egg-info

# Install dependencies
# "download and install the deps" as requested
#echo "Installing dependencies..."
#pip install --upgrade pip build twine
#pip install .
#if [ -d "requirements" ]; then
#    for req in requirements/*.txt; do
#        if [ -f "$req" ] && [[ "$req" != *"test.txt" ]]; then
#            pip install -r "$req"
#        fi
#    done
#fi

# Build only the dmart package
# python3 -m build creates sdist and wheel for the current package only
echo "Building dmart..."
python3 -m build

# Upload to PyPI
# Using dist/* to upload only the newly built dmart package
echo "Uploading to PyPI..."
twine upload --non-interactive dist/*
