*: fix release script

This commit is contained in:
Eric Chiang 2016-03-02 12:03:13 -08:00
parent 93b89ad0e9
commit 91ef40b124
3 changed files with 26 additions and 10 deletions

17
build
View file

@ -2,9 +2,18 @@
source ./env
go install -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dex-worker
go install -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dexctl
go install -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dex-overlord
CMDS=( "dex-worker" "dexctl" "dex-overlord" "gendoc")
FORMAT='{{ range $i, $dep := .Deps }}{{ $dep }} {{ end }}'
for CMD in ${CMDS[@]}; do
TARGET="github.com/coreos/dex/cmd/$CMD"
# Install command dependencies. This caches package builds and speeds
# up successive builds a lot.
go list -f="$FORMAT" $TARGET | xargs go install -ldflags="$LD_FLAGS"
# Build the actual command.
go build -o="bin/$CMD" -ldflags="$LD_FLAGS" $TARGET
done
go build -o bin/example-app github.com/coreos/dex/examples/app
go build -o bin/example-cli github.com/coreos/dex/examples/cli
go install github.com/coreos/dex/cmd/gendoc

5
env
View file

@ -1,5 +1,4 @@
export GOPATH=${PWD}/Godeps/_workspace
export GOBIN=${PWD}/bin
rm -rf $GOPATH/src/github.com/coreos/dex
mkdir -p $GOPATH/src/github.com/coreos/
@ -7,4 +6,6 @@ mkdir -p $GOPATH/src/github.com/coreos/
# Only attempt to link dex into godeps if it isn't already there
[ -d $GOPATH/src/github.com/coreos/dex ] || ln -s ${PWD} $GOPATH/src/github.com/coreos/dex
LD_FLAGS="-X main.version=$(./git-version)"
export VERSION=$(./git-version)
LD_FLAGS="-X main.version=${VERSION}"

14
release
View file

@ -1,18 +1,24 @@
#!/bin/bash -e
VERSION=$(./git-version)
GOARCH=amd64
OSS=( "darwin" "linux" )
source ./env
# cannot cross compile when GOBIN is set.
# See:
# https://golang.org/issue/9769
# https://golang.org/issue/11778
unset GOBIN
for GOOS in ${OSS[@]}; do
name=dex-$VERSION-$GOOS-$GOARCH
rm -fr $name.tar.gz $name/
mkdir $name
GOOS=$GOOS GOARCH=$GOARCH ./build
cp bin/dexctl $name/
GOOS=$GOOS GOARCH=$GOARCH go build -o $name/dexctl -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dexctl
tar -czf $name.tar.gz $name/
echo "Created ${name}.tar.gz"