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-15 17:06:25 +00:00
|
|
|
cross build --release --locked --target "$target" --features vendored-openssl
|
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-03-11 14:30:25 +00:00
|
|
|
cd "${NAVI_HOME}/target/tar"
|
|
|
|
tar -czf navi.tar.gz *
|
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-03-04 21:01:23 +00:00
|
|
|
esac
|