-
-
Notifications
You must be signed in to change notification settings - Fork 384
/
build.sh
65 lines (57 loc) · 1.41 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
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
VERSION="1.4.6"
PROTECTED_MODE="no"
export GO15VENDOREXPERIMENT=1
cd $(dirname "${BASH_SOURCE[0]}")
OD="$(pwd)"
WD=$OD
package() {
echo Packaging $1 Binary
bdir=caire-${VERSION}-$2-$3
rm -rf packages/$bdir && mkdir -p packages/$bdir
GOOS=$2 GOARCH=$3 ./build.sh
if [ "$2" == "windows" ]; then
mv caire packages/$bdir/caire.exe
else
mv caire packages/$bdir
fi
cp README.md packages/$bdir
cd packages
if [ "$2" == "linux" ]; then
tar -zcf $bdir.tar.gz $bdir
else
zip -r -q $bdir.zip $bdir
fi
rm -rf $bdir
cd ..
}
if [ "$1" == "package" ]; then
rm -rf packages/
package "Windows" "windows" "amd64"
package "Mac" "darwin" "amd64"
package "Linux" "linux" "amd64"
package "FreeBSD" "freebsd" "amd64"
exit
fi
# temp directory for storing isolated environment.
TMP="$(mktemp -d -t sdb.XXXX)"
rmtemp() {
rm -rf "$TMP"
}
trap rmtemp EXIT
if [ "$NOCOPY" != "1" ]; then
# copy all files to an isolated directory.
WD="$TMP/src/github.com/esimov/caire"
export GOPATH="$TMP"
for file in `find . -type f`; do
# TODO: use .gitignore to ignore, or possibly just use git to determine the file list.
if [[ "$file" != "." && "$file" != ./.git* && "$file" != ./caire ]]; then
mkdir -p "$WD/$(dirname "${file}")"
cp -P "$file" "$WD/$(dirname "${file}")"
fi
done
cd $WD
fi
# build and store objects into original directory.
go build -ldflags "-X main.Version=$VERSION" -o "$OD/caire" cmd/caire/*.go