diff --git a/build b/build index 4052d13c..0493c3e1 100755 --- a/build +++ b/build @@ -25,7 +25,7 @@ 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 rev-parse HEAD)" +LD_FLAGS="-X main.version=$(./git-version)" go build -o bin/dex-worker -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dex-worker go build -o bin/dexctl github.com/coreos/dex/cmd/dexctl go build -o bin/dex-overlord -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dex-overlord diff --git a/build-docker-push b/build-docker-push index e6a44647..cd9e9662 100755 --- a/build-docker-push +++ b/build-docker-push @@ -12,9 +12,9 @@ else docker login --username="$DOCKER_USER" --password="$DOCKER_PASSWORD" --email="dex@example.com" $DOCKER_REGISTRY fi -git_sha=$(git rev-parse HEAD) +version=$(./git-version) -docker build -q --rm=true -t $repo:$git_sha . -docker tag -f $repo:$git_sha $repo:latest -docker push $repo:$git_sha +docker build -q --rm=true -t $repo:$version . +docker tag -f $repo:$version $repo:latest +docker push $repo:$version docker push $repo:latest diff --git a/git-version b/git-version new file mode 100755 index 00000000..2a83e225 --- /dev/null +++ b/git-version @@ -0,0 +1,21 @@ +#!/bin/bash -e + +# pull the current git commit hash +COMMIT=`git rev-parse HEAD` + +# check if the current commit has a matching tag +TAG=$(git describe --exact-match --abbrev=0 --tags ${COMMIT} 2> /dev/null || true) + +# use the matching tag as the version, if available +if [ -z "$TAG" ]; then + VERSION=$COMMIT +else + VERSION=$TAG +fi + +# check for changed files (not untracked files) +if [ -n "$(git diff --shortstat 2> /dev/null | tail -n1)" ]; then + VERSION="${VERSION}+dirty" +fi + +echo $VERSION diff --git a/release b/release new file mode 100755 index 00000000..602c3ec8 --- /dev/null +++ b/release @@ -0,0 +1,21 @@ +#!/bin/bash -e + +VERSION=$(./git-version) + +GOARCH=amd64 +OSS=( "darwin" "linux" ) + +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/ + + tar -czf $name.tar.gz $name/ + echo "Created ${name}.tar.gz" + + rm -fr $name/ +done