From 49b74d189e4e0ff2fe0db89c047840876963387d Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Sun, 10 Dec 2023 13:08:23 +1100 Subject: [PATCH] feat(installer): improve messages, simplify script - Color outputs - Clarify messages - Do not offer to use existing frontend build (insurance - prevents accidentally using old build) --- installer/create_installer.sh | 92 +++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 30 deletions(-) diff --git a/installer/create_installer.sh b/installer/create_installer.sh index d36e3f1887..278a7ed94a 100755 --- a/installer/create_installer.sh +++ b/installer/create_installer.sh @@ -2,16 +2,36 @@ set -e -cd "$(dirname "$0")" +BCYAN="\e[1;36m" +BBLUE="\e[1;34m" +BYELLOW="\e[1;33m" +BGREEN="\e[1;32m" +RED="\e[31m" +RESET="\e[0m" function is_bin_in_path { builtin type -P "$1" &>/dev/null } +function git_show_ref { + git show-ref --dereference $1 --abbrev 7 +} + +function git_show { + git show -s --format='%h %s' $1 +} + +cd "$(dirname "$0")" + +echo -e "${BYELLOW}This script must be run from the installer directory!${RESET}" +echo "The current working directory is $(pwd)" +read -p "If that looks right, press any key to proceed, or CTRL-C to exit..." +echo + # Some machines only have `python3`, others have `python` - make an alias. # We can use a function to approximate an alias within a non-interactive shell. if ! is_bin_in_path python && is_bin_in_path python3; then - echo "Aliasing python3 to python..." + echo -e "Aliasing ${BBLUE}python3${RESET} to ${BBLUE}python${RESET}..." function python { python3 "$@" } @@ -20,7 +40,7 @@ fi if [[ -v "VIRTUAL_ENV" ]]; then # we can't just call 'deactivate' because this function is not exported # to the environment of this script from the bash process that runs the script - echo "A virtual environment is activated. Please deactivate it before proceeding". + echo -e "${BYELLOW}A virtual environment is activated. Please deactivate it before proceeding.${RESET}" exit -1 fi @@ -32,51 +52,61 @@ PATCH="" VERSION="v${VERSION}${PATCH}" LATEST_TAG="v3-latest" -echo Building installer for version $VERSION -echo "Be certain that you're in the 'installer' directory before continuing. Currently in '$(pwd)'." -read -p "Press any key to continue, or CTRL-C to exit..." +echo "Building installer for version $VERSION..." +echo -read -e -p "Tag this repo with '${VERSION}' and '${LATEST_TAG}'? Immediately deletes the existing tags! [n]: " input +echo -e "${BCYAN}$VERSION${RESET}" +git_show_ref tags/$VERSION +echo +echo -e "${BCYAN}$LATEST_TAG${RESET}" +git_show_ref tags/$LATEST_TAG +echo +echo -e "${BGREEN}HEAD${RESET}" +git_show +echo + +echo -e -n "Tag ${BGREEN}HEAD${RESET} with ${BCYAN}${VERSION}${RESET} and ${BCYAN}${LATEST_TAG}${RESET}, ${RED}deleting existing tags on remote${RESET}? " +read -e -p 'y/n [n]: ' input RESPONSE=${input:='n'} if [ "$RESPONSE" == 'y' ]; then - - echo "Deleting '$VERSION' and '$LATEST_TAG' tags..." + echo + echo -e "Deleting ${BCYAN}${VERSION}${RESET} tag on remote..." git push origin :refs/tags/$VERSION + + echo -e "Tagging ${BGREEN}HEAD${RESET} with ${BCYAN}${VERSION}${RESET} locally..." if ! git tag -fa $VERSION; then echo "Existing/invalid tag" exit -1 fi + echo -e "Deleting ${BCYAN}${LATEST_TAG}${RESET} tag on remote..." git push origin :refs/tags/$LATEST_TAG + + echo -e "Tagging ${BGREEN}HEAD${RESET} with ${BCYAN}${LATEST_TAG}${RESET} locally..." git tag -fa $LATEST_TAG - echo "Remember to push --tags!" + echo + echo -e "${BYELLOW}Remember to 'git push origin --tags'!${RESET}" fi # ---------------------- FRONTEND ---------------------- -function build_frontend { - echo Building frontend - pushd ../invokeai/frontend/web - pnpm i --frozen-lockfile - pnpm build - popd -} - -# Build frontend if needed - offer to rebuild if there is already a build -if [ -d ../invokeai/frontend/web/dist ]; then - read -e -p "Frontend build exists. Rebuild? [n]: " input - RESPONSE=${input:='n'} - if [ "$RESPONSE" == 'y' ]; then - build_frontend - fi -else - build_frontend -fi +pushd ../invokeai/frontend/web >/dev/null +echo +echo "Installing frontend dependencies..." +echo +pnpm i --frozen-lockfile +echo +echo "Building frontend..." +echo +pnpm build +popd # ---------------------- BACKEND ---------------------- -echo Building the wheel +echo +echo "Building wheel..." +echo # install the 'build' package in the user site packages, if needed # could be improved by using a temporary venv, but it's tiny and harmless @@ -90,7 +120,9 @@ python -m build --wheel --outdir dist/ ../. # ---------------------- -echo Building installer zip files for InvokeAI $VERSION +echo +echo "Building installer zip files for InvokeAI ${VERSION}..." +echo # get rid of any old ones rm -f *.zip