#!/bin/bash
set -e
BCYAN="\033[1;36m"
BYELLOW="\033[1;33m"
BGREEN="\033[1;32m"
BRED="\033[1;31m"
RED="\033[31m"
RESET="\033[0m"
function git_show {
git show -s --format=oneline --abbrev-commit "$1" | cat
}
if [[ ! -z "${VIRTUAL_ENV}" ]]; then
echo -e "${BRED}A virtual environment is activated. Please deactivate it before proceeding.${RESET}"
exit -1
fi
cd "$(dirname "$0")"
VERSION=$(
cd ..
python3 -c "from invokeai.version import __version__ as version; print(version)"
)
VERSION="v${VERSION}"
if [[ ! -z ${CI} ]]; then
echo
echo -e "${BCYAN}CI environment detected${RESET}"
echo
fi
echo -e "${BGREEN}HEAD${RESET}:"
git_show HEAD
echo
echo "Checking pyproject classifiers..."
python3 ./check_classifiers.py ../pyproject.toml
echo
for frontend in webv2 webv1; do
pushd "../invokeai/frontend/$frontend" >/dev/null
echo "Installing $frontend dependencies..."
pnpm install --frozen-lockfile
if [[ ! -z ${CI} ]]; then
pnpm exec vite build
else
pnpm build
fi
popd
done
echo
echo "Building wheel..."
echo
if [[ $(python3 -c 'from importlib.util import find_spec; print(find_spec("build") is None)') == "True" ]]; then
pip install --user build
fi
rm -rf ../build
python3 -m build --outdir ../dist/ ../.
echo -e "${BGREEN}Built PyPi distribution: ./dist${RESET}"
if [[ -z ${CI} ]]; then
echo
echo "Cleaning up intermediate build files..."
rm -rf InvokeAI-Installer tmp ../invokeai/frontend/webv2/dist/ ../invokeai/frontend/webv1/dist/
fi
if [[ ! -z ${CI} ]]; then
echo
echo "Setting GitHub action outputs..."
echo "DIST_PATH=./dist/" >>$GITHUB_OUTPUT
fi
exit 0