Merge pull request #221 from coreos/release-scripts

Release scripts
This commit is contained in:
bobbyrullo 2015-12-16 14:30:27 -08:00
commit b5164994e1
4 changed files with 47 additions and 5 deletions

2
build
View file

@ -25,7 +25,7 @@ mkdir -p $GOPATH/src/github.com/coreos/
# Only attempt to link dex into godeps if it isn't already there # 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 [ -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/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/dexctl github.com/coreos/dex/cmd/dexctl
go build -o bin/dex-overlord -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dex-overlord go build -o bin/dex-overlord -ldflags="$LD_FLAGS" github.com/coreos/dex/cmd/dex-overlord

View file

@ -12,9 +12,9 @@ else
docker login --username="$DOCKER_USER" --password="$DOCKER_PASSWORD" --email="dex@example.com" $DOCKER_REGISTRY docker login --username="$DOCKER_USER" --password="$DOCKER_PASSWORD" --email="dex@example.com" $DOCKER_REGISTRY
fi fi
git_sha=$(git rev-parse HEAD) version=$(./git-version)
docker build -q --rm=true -t $repo:$git_sha . docker build -q --rm=true -t $repo:$version .
docker tag -f $repo:$git_sha $repo:latest docker tag -f $repo:$version $repo:latest
docker push $repo:$git_sha docker push $repo:$version
docker push $repo:latest docker push $repo:latest

21
git-version Executable file
View file

@ -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

21
release Executable file
View file

@ -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