mirror of https://github.com/tidwall/tile38.git
Use travis vars
This commit is contained in:
parent
1b38bf1993
commit
e60191caed
|
@ -7,4 +7,4 @@ script:
|
||||||
- make test
|
- make test
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- ./build.sh docker-push
|
- ./build.sh travis-docker-push
|
||||||
|
|
27
build.sh
27
build.sh
|
@ -24,9 +24,7 @@ if [ "$1" == "update-version" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" == "docker-push" ]; then
|
if [ "$1" == "travis-docker-push" ]; then
|
||||||
# GIT_BRANCH - such as master or something else.
|
|
||||||
export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
||||||
# GIT_VERSION - always the last verison number, like 1.12.1.
|
# GIT_VERSION - always the last verison number, like 1.12.1.
|
||||||
export GIT_VERSION=$(git describe --tags --abbrev=0)
|
export GIT_VERSION=$(git describe --tags --abbrev=0)
|
||||||
# GIT_TAG - either a version number, like 1.12.1, or the commit after the version, like 1.12.1-10-a718ef0.
|
# GIT_TAG - either a version number, like 1.12.1, or the commit after the version, like 1.12.1-10-a718ef0.
|
||||||
|
@ -35,26 +33,13 @@ if [ "$1" == "docker-push" ]; then
|
||||||
export GIT_COMMIT_SHORT=$(git rev-parse --short HEAD)
|
export GIT_COMMIT_SHORT=$(git rev-parse --short HEAD)
|
||||||
# DOCKER_REPO - the base repository name to push the docker build to.
|
# DOCKER_REPO - the base repository name to push the docker build to.
|
||||||
export DOCKER_REPO=$DOCKER_USER/tile38
|
export DOCKER_REPO=$DOCKER_USER/tile38
|
||||||
if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||||
# never push from a pull request
|
# never push from a pull request
|
||||||
echo "Not pushing, on a PR"
|
echo "Not pushing, on a PR or not running in Travis CI"
|
||||||
exit
|
elif [ "$TRAVIS_BRANCH" != "master" ]; then
|
||||||
fi
|
|
||||||
if [ "$GIT_BRANCH" != "master" ]; then
|
|
||||||
# only the master branch will work
|
# only the master branch will work
|
||||||
echo "Not pushing, not on master"
|
echo "Not pushing, not on master"
|
||||||
exit
|
else
|
||||||
fi
|
|
||||||
if [ "$(git status | grep "nothing to commit, working tree clean")" == "" ]; then
|
|
||||||
# there's stuff to
|
|
||||||
echo "Not pushing, local git repo is dirty"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
if [ "$(git status | grep "branch is up-to-date")" == "" ]; then
|
|
||||||
# branch must be up-to-date
|
|
||||||
echo "Not pushing, branch is not up-to-date with master"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
push(){
|
push(){
|
||||||
docker tag $DOCKER_REPO:$GIT_COMMIT_SHORT $DOCKER_REPO:$1
|
docker tag $DOCKER_REPO:$GIT_COMMIT_SHORT $DOCKER_REPO:$1
|
||||||
docker push $DOCKER_REPO:$1
|
docker push $DOCKER_REPO:$1
|
||||||
|
@ -64,12 +49,12 @@ if [ "$1" == "docker-push" ]; then
|
||||||
echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin
|
echo $DOCKER_PASSWORD | docker login -u $DOCKER_LOGIN --password-stdin
|
||||||
# build the docker image
|
# build the docker image
|
||||||
docker build -f Dockerfile -t $DOCKER_REPO:$GIT_COMMIT_SHORT .
|
docker build -f Dockerfile -t $DOCKER_REPO:$GIT_COMMIT_SHORT .
|
||||||
|
|
||||||
if [ "$GIT_VERSION" == "$GIT_TAG" ]; then
|
if [ "$GIT_VERSION" == "$GIT_TAG" ]; then
|
||||||
push "$GIT_VERSION"
|
push "$GIT_VERSION"
|
||||||
push "latest"
|
push "latest"
|
||||||
fi
|
fi
|
||||||
push "edge"
|
push "edge"
|
||||||
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue