hs.scripts/updates/keila.sh

52 lines
1.0 KiB
Bash
Raw Permalink Normal View History

2024-04-25 13:49:12 +02:00
set -e
export XDG_RUNTIME_DIR=/run/user/$UID
export MIX_ENV=prod
basedir=$HOME/var/keila
release=`curl -Ls https://api.github.com/repos/pentacent/keila/releases/latest | jq -r '.tag_name'`
oldrelease=`$HOME/bin/keila version | cut -d " " -f2-`
tools=$basedir/.tool-versions
erlang_ver=$(grep "erlang" "$tools" | awk '{print $2}')
elixir_ver=$(grep "elixir" "$tools" | awk '{print $2}')
echo "=== Old Keila is at [ $oldrelease ], latest release is [ $release ] ==="
read -p "=> Reply yY to proceed..." -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
cd $basedir
git fetch
git checkout $release
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
asdf install erlang $erlang_ver
asdf install elixir $elixir_ver
systemctl stop --user keila
cd $basedir
mix local.hex --force
mix local.rebar --force
mix deps.get
mix deps.compile
npm ci --prefix ./assets
mix deps.clean mime --build
mix assets.deploy
mix release
systemctl start --user keila
sleep 2
systemctl status --user keila