-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
53 lines (34 loc) · 974 Bytes
/
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
#!/bin/bash
set -Eeuo pipefail
[ -z ${1-} ] && { echo "use build.sh VersionCore [PreRelease]"; exit 1; }
BuildFolder=".build"
# Process arguments
VersionCore=$1
PreRelease=${2-}
[ -z ${PreRelease-} ] && SemVer=$VersionCore || SemVer=$VersionCore-$PreRelease
echo $SemVer > version
# Functions
function cleanup {
# Restore version
git checkout -- version
}
function build_os_arch {
[ $1 == "windows" ] && exeName="ce.exe" || exeName="ce"
echo "building GOOS=$1 GOARCH=$2..."
env GOOS=$1 GOARCH=$2 go build -o $BuildFolder/$exeName
pushd $BuildFolder > /dev/null
tar -czvf ce_v${SemVer}_$1_$2.tar.gz $exeName > /dev/null
popd > /dev/null
rm $BuildFolder/$exeName
}
# End of functions
trap cleanup EXIT
# Cleanup
rm -rf $BuildFolder
[ -d "$BuildFolder" ] || mkdir $BuildFolder
# Build os+arch
build_os_arch linux amd64
build_os_arch freebsd amd64
build_os_arch windows amd64
cp install/install.sh $BuildFolder
cp version $BuildFolder