export TWINE_NON_INTERACTIVE=0

# create a fresh .venv with necessary tools in it
rm -rf .venv;
python -m venv .venv
source .venv/bin/activate
pip install build==1.3.0 twine==6.2.0 setuptools==77.0.3 --quiet

# remove old dist artifacts
rm this_is_a_package/dist/*

for mode in "TIMESTAMP 0.1.0" "CHECKED_HASH 0.2.0" "UNCHECKED_HASH 0.3.0"
do
    set -- $mode

    # remove old cache
    rm -rf "./this_is_a_package/src/this_is_a_package/__pycache__"

    # set version and description in pyproject.toml
    sed -i -e 's/version = .*/version = "'$2'"/g' ./this_is_a_package/pyproject.toml
    sed -i -e 's/description = .*/description = "'$1'"/g' ./this_is_a_package/pyproject.toml

    # compile and manipulate cache
    python compile_and_poison.py $1

    # remove old build information
    rm -rf this_is_a_package.egg-info

    # build the package
    python -m build ./this_is_a_package

done

# upload all dists to our registgy
python -m twine upload this_is_a_package/dist/*
