2020-03-04 21:01:23 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
##? action release
|
|
|
|
|
|
|
|
export NAVI_HOME="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
source "${NAVI_HOME}/scripts/install"
|
|
|
|
|
|
|
|
release() {
|
|
|
|
|
2020-03-11 14:30:25 +00:00
|
|
|
TAR_DIR="${NAVI_HOME}/target/tar"
|
2020-03-04 21:01:23 +00:00
|
|
|
|
2020-03-11 14:30:25 +00:00
|
|
|
target="${1:-}"
|
|
|
|
if [[ $target == *"osx"* ]]; then
|
|
|
|
echoerr "OSX cross-compile is impossible. Fallbacking to cargo..."
|
|
|
|
target=""
|
|
|
|
fi
|
2020-03-04 21:01:23 +00:00
|
|
|
|
2020-03-11 14:30:25 +00:00
|
|
|
cd "$NAVI_HOME"
|
2020-03-04 21:01:23 +00:00
|
|
|
|
2020-03-11 14:30:25 +00:00
|
|
|
rm -rf "${NAVI_HOME}/target" 2> /dev/null || true
|
2020-03-04 21:01:23 +00:00
|
|
|
|
2020-03-11 14:30:25 +00:00
|
|
|
if [ -n "$target" ]; then
|
|
|
|
cargo install cross 2> /dev/null || true
|
2020-03-16 11:02:23 +00:00
|
|
|
cross build --release --locked --target "$target"
|
2020-03-11 14:30:25 +00:00
|
|
|
bin_folder="${target}/release"
|
|
|
|
else
|
|
|
|
cargo build --release --locked
|
|
|
|
bin_folder="release"
|
|
|
|
fi
|
2020-03-04 21:01:23 +00:00
|
|
|
|
2020-03-11 14:30:25 +00:00
|
|
|
bin_path="${NAVI_HOME}/target/${bin_folder}/navi"
|
|
|
|
chmod +x "$bin_path"
|
|
|
|
mkdir -p "$TAR_DIR" 2> /dev/null || true
|
2020-03-04 21:01:23 +00:00
|
|
|
|
2020-03-11 14:30:25 +00:00
|
|
|
cp "$bin_path" "$TAR_DIR"
|
2020-03-04 21:01:23 +00:00
|
|
|
|
2020-04-19 18:51:04 +00:00
|
|
|
cd "$TAR_DIR"
|
2020-03-11 14:30:25 +00:00
|
|
|
tar -czf navi.tar.gz *
|
2020-03-04 21:01:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-19 18:51:04 +00:00
|
|
|
workflow() {
|
|
|
|
|
|
|
|
WORKFLOW_DIR="${NAVI_HOME}/target/workflow"
|
|
|
|
|
|
|
|
cd "$NAVI_HOME"
|
|
|
|
|
|
|
|
rm -rf "${NAVI_HOME}/target" 2> /dev/null || true
|
|
|
|
|
|
|
|
mkdir -p "$WORKFLOW_DIR" 2> /dev/null || true
|
|
|
|
|
2020-04-19 19:02:34 +00:00
|
|
|
cp ${NAVI_HOME}/alfred/* "$WORKFLOW_DIR"
|
2020-04-19 18:51:04 +00:00
|
|
|
cd "$WORKFLOW_DIR"
|
2020-04-19 19:02:34 +00:00
|
|
|
zip -j -r navi.zip *
|
2020-04-19 18:51:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-03-04 21:01:23 +00:00
|
|
|
cmd="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
case "$cmd" in
|
2020-03-11 14:30:25 +00:00
|
|
|
"release") release "$@" ;;
|
2020-04-19 18:51:04 +00:00
|
|
|
"workflow") workflow "$@" ;;
|
2020-03-04 21:01:23 +00:00
|
|
|
esac
|