-
Notifications
You must be signed in to change notification settings - Fork 26
/
dist.sh
executable file
·37 lines (32 loc) · 1.08 KB
/
dist.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
#!/bin/bash
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rm -rf $DIR/dist/docker
mkdir -p $DIR/dist/docker
rm -rf $DIR/.godeps
mkdir -p $DIR/.godeps
export GOPATH=$DIR/vendor:$GOPATH
arch=$(go env GOARCH)
version=$(awk '/const Version/ {print $NF}' < $DIR/internal/version/version.go | sed 's/"//g')
goversion=$(go version | awk '{print $3}')
for os in linux darwin freebsd; do
echo "... building v$version for $os/$arch"
BUILD=$(mktemp -d -t phosphor)
TARGET="phosphor-$version.$os-$arch.$goversion"
for app in phosphor phosphord; do
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -o $BUILD/$TARGET/bin/$app ./apps/$app
done
pushd $BUILD
if [ "$os" == "linux" ]; then
cp -r $TARGET/bin $DIR/dist/docker/
fi
tar czvf $TARGET.tar.gz $TARGET
mv $TARGET.tar.gz $DIR/dist
popd
rm -r $BUILD
done
docker build -t mondough/phosphor:v$version .
if [[ ! $version == *"-"* ]]; then
echo "Tagging mondough/phosphor:v$version as the latest release."
docker tag -f mondough/phosphor:v$version mondough/phosphor:latest
fi