-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
53 lines (46 loc) · 1.49 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
set -o errexit
set -o pipefail
TARGET_LINUX=x86_64-unknown-linux-gnu
TARGET_WIN=x86_64-pc-windows-gnu
BIN_NAME=$(grep name Cargo.toml | sed -e 's/.* = "\(.*\)"/\1/')
VERSION=$(grep version Cargo.toml | sed -e 's/.* = "\(.*\)"/\1/')
USAGE="Build script for $BIN_NAME.
USAGE
build.sh <target>
TARGETS
build_linux cargo release build for 64bit linux
build_win cargo release build for 64bit windows
debug_linux cargo build for 64bit linux
debug_windows cargo build for 64bit windows
check start a 'cargo watch' job with check
install run cargo install to cargo's bin dir
publish publish to crates.io
release create a new github release with both linux and win binaries
"
gh_release() {
gh release create "v${VERSION}" --title "Release ${VERSION}" target/${TARGET_WIN}/release/${BIN_NAME}.exe target/${TARGET_LINUX}/release/${BIN_NAME}
git fetch --tags origin
rm VERSION
}
case $1 in
build_linux)
cargo build --release --target=$TARGET_LINUX ;;
debug_linux)
cargo build --target=$TARGET_LINUX ;;
build_win)
cargo build --release --target=$TARGET_WIN ;;
debug_win)
cargo build --target=$TARGET_WIN ;;
check)
cargo watch -x check ;;
install)
cargo install --path . --force ;;
publish)
cargo publish ;;
name)
echo $BIN_NAME ;;
release) gh_release ;;
*)
echo "$USAGE" ;;
esac