#!/bin/bash

TS=$(date +20%y%m%d-%H%M%S)
HOSHINOVA_ROOT_DIR='/root/hoshinova'
BUILT_BIN='/target/debug/hoshinova'
HOSHINOVA_BIN_PATH="/root/hoshinova/bin"

F_NAME="hoshinova_${TS}"

#git pull && cargo test && cd web && yarn && yarn build

# MARK: Move to Git Root Directory
cd ${HOSHINOVA_ROOT_DIR} && \
git pull && \
cargo test && \
cd web && \
yarn && \
yarn build && \
cd ${HOSHINOVA_ROOT_DIR} && \
cargo build && \
mv "${HOSHINOVA_ROOT_DIR}${BUILT_BIN}" "${HOSHINOVA_BIN_PATH}/${F_NAME}" && \
rm -f "${HOSHINOVA_BIN_PATH}/hoshinova" && \
ln -s "${HOSHINOVA_BIN_PATH}/${F_NAME}" "${HOSHINOVA_BIN_PATH}/hoshinova"
