diff --git a/build b/build
index 4052d13cece956c69287a10952cc2c47c8352b40..0493c3e12697f5014eb99f723c44027b441e6431 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 e6a446470ae851b4b842e5bd9218f61f5c83b328..cd9e96627ffbe034fad61b212209493be3aa3eb8 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 0000000000000000000000000000000000000000..2a83e225253bf50ee80d36bdd0de45e0db36576b
--- /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 0000000000000000000000000000000000000000..602c3ec87608af16322d08fd08c923cd46e451ec
--- /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