mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(installer): improve messages, simplify script
- Color outputs - Clarify messages - Do not offer to use existing frontend build (insurance - prevents accidentally using old build)
This commit is contained in:
parent
179bc64490
commit
49b74d189e
@ -2,16 +2,36 @@
|
|||||||
|
|
||||||
set -e
|
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 {
|
function is_bin_in_path {
|
||||||
builtin type -P "$1" &>/dev/null
|
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.
|
# 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.
|
# 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
|
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 {
|
function python {
|
||||||
python3 "$@"
|
python3 "$@"
|
||||||
}
|
}
|
||||||
@ -20,7 +40,7 @@ fi
|
|||||||
if [[ -v "VIRTUAL_ENV" ]]; then
|
if [[ -v "VIRTUAL_ENV" ]]; then
|
||||||
# we can't just call 'deactivate' because this function is not exported
|
# 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
|
# 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
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -32,51 +52,61 @@ PATCH=""
|
|||||||
VERSION="v${VERSION}${PATCH}"
|
VERSION="v${VERSION}${PATCH}"
|
||||||
LATEST_TAG="v3-latest"
|
LATEST_TAG="v3-latest"
|
||||||
|
|
||||||
echo Building installer for version $VERSION
|
echo "Building installer for version $VERSION..."
|
||||||
echo "Be certain that you're in the 'installer' directory before continuing. Currently in '$(pwd)'."
|
echo
|
||||||
read -p "Press any key to continue, or CTRL-C to exit..."
|
|
||||||
|
|
||||||
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'}
|
RESPONSE=${input:='n'}
|
||||||
if [ "$RESPONSE" == 'y' ]; then
|
if [ "$RESPONSE" == 'y' ]; then
|
||||||
|
echo
|
||||||
echo "Deleting '$VERSION' and '$LATEST_TAG' tags..."
|
echo -e "Deleting ${BCYAN}${VERSION}${RESET} tag on remote..."
|
||||||
git push origin :refs/tags/$VERSION
|
git push origin :refs/tags/$VERSION
|
||||||
|
|
||||||
|
echo -e "Tagging ${BGREEN}HEAD${RESET} with ${BCYAN}${VERSION}${RESET} locally..."
|
||||||
if ! git tag -fa $VERSION; then
|
if ! git tag -fa $VERSION; then
|
||||||
echo "Existing/invalid tag"
|
echo "Existing/invalid tag"
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e "Deleting ${BCYAN}${LATEST_TAG}${RESET} tag on remote..."
|
||||||
git push origin :refs/tags/$LATEST_TAG
|
git push origin :refs/tags/$LATEST_TAG
|
||||||
|
|
||||||
|
echo -e "Tagging ${BGREEN}HEAD${RESET} with ${BCYAN}${LATEST_TAG}${RESET} locally..."
|
||||||
git tag -fa $LATEST_TAG
|
git tag -fa $LATEST_TAG
|
||||||
|
|
||||||
echo "Remember to push --tags!"
|
echo
|
||||||
|
echo -e "${BYELLOW}Remember to 'git push origin --tags'!${RESET}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---------------------- FRONTEND ----------------------
|
# ---------------------- FRONTEND ----------------------
|
||||||
|
|
||||||
function build_frontend {
|
pushd ../invokeai/frontend/web >/dev/null
|
||||||
echo Building frontend
|
echo
|
||||||
pushd ../invokeai/frontend/web
|
echo "Installing frontend dependencies..."
|
||||||
pnpm i --frozen-lockfile
|
echo
|
||||||
pnpm build
|
pnpm i --frozen-lockfile
|
||||||
popd
|
echo
|
||||||
}
|
echo "Building frontend..."
|
||||||
|
echo
|
||||||
# Build frontend if needed - offer to rebuild if there is already a build
|
pnpm build
|
||||||
if [ -d ../invokeai/frontend/web/dist ]; then
|
popd
|
||||||
read -e -p "Frontend build exists. Rebuild? [n]: " input
|
|
||||||
RESPONSE=${input:='n'}
|
|
||||||
if [ "$RESPONSE" == 'y' ]; then
|
|
||||||
build_frontend
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
build_frontend
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---------------------- BACKEND ----------------------
|
# ---------------------- BACKEND ----------------------
|
||||||
|
|
||||||
echo Building the wheel
|
echo
|
||||||
|
echo "Building wheel..."
|
||||||
|
echo
|
||||||
|
|
||||||
# install the 'build' package in the user site packages, if needed
|
# 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
|
# 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
|
# get rid of any old ones
|
||||||
rm -f *.zip
|
rm -f *.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user