-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
33 lines (27 loc) · 1.02 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
# 設定
APP_NAME="kcl-go"
APP_OS="linux darwin windows"
APP_ARCH="386 amd64"
# Go1.2.1をダウンロードする
pushd ~/
curl -s -o go.tar.gz https://go.googlecode.com/files/go1.2.1.linux-amd64.tar.gz
tar xzf go.tar.gz
export GOROOT=~/go
export PATH=$GOROOT/bin:$PATH
go version
popd
# goxをインストールする
go get github.com/mitchellh/gox
gox -build-toolchain -os="$APP_OS" -arch="$APP_ARCH"
# gitのコミットからバージョンを採番する
APP_VERSION=$(git log --pretty=format:"%h (%ad)" --date=short -1)
echo APP_VERSION is $APP_VERSION
# 必要なライブラリを集める
go get github.com/mitchellh/cli
# リリース用ディレクトリ作成
mkdir -p artifacts
# クロスコンパイルする
gox ./cmd/kclgo -os="$APP_OS" -arch="$APP_ARCH" -output="artifacts/{{.OS}}-{{.Arch}}/$APP_NAME" -ldflags "-X main.version '$APP_VERSION'"
find artifacts
gox ./cmd/kclsample -os="$APP_OS" -arch="$APP_ARCH" -output="artifacts/{{.OS}}-{{.Arch}}/$APP_NAME" -ldflags "-X main.version '$APP_VERSION'"
find artifacts