diff --git a/.travis.yml b/.travis.yml index cbee329ac7dd..92378bbfe665 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,22 +7,22 @@ matrix: include: - env: ARCH=i386 ARCH_CMD=linux32 os: linux - - env: ARCH=x86_64 ARCH_CMD=linux64 + - env: ARCH=x86_64 ARCH_CMD=linux64 DEPLOY=true os: linux - os: osx - os: osx osx_image: xcode7.3 -before_install: bin/ci prepare_system -install: bin/ci prepare_build +before_install: + - bin/ci prepare_system +install: + - bin/ci prepare_build script: - - bin/ci with_build_env 'make std_spec clean' - - bin/ci with_build_env 'make crystal std_spec compiler_spec doc' - - bin/ci with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal build --no-codegen' - - bin/ci with_build_env './bin/crystal tool format --check' + - bin/ci build +after_success: + - bin/ci deploy branches: only: - master - - gh-pages - /\Arelease\/.+\z/ notifications: irc: @@ -34,3 +34,7 @@ notifications: - "%{repository_slug}#%{commit} (%{branch} - %{commit_subject}): %{message} %{build_url}" slack: secure: Ng3nTqGWY+9p1pS6yjGqDhmRvdgbIZgTNpMWbO/ngwpCyicmD3jafZkShqqXbULZTJJr3OxIGzi6GHGusT0Ic/Pi9JCM3X3v/xuBruKIR+EnNyPo7IL4ZYAlwnXyJHlCHHDBq0gSHGvGJwsXn6IgZBPRfeIq+CCyQHVPyvc9EHE= +env: + global: + - AWS_ACCESS_KEY_ID=AKIAIRL4BWFPN7P54TBQ + - secure: Zd/tZVmV2dRMao9z+ky5BywSKuWOF3MiKsZetwd1upZ+uj9qzfbOZMnWFW9dlA+Co4MyYqP/I6ADzRpoKLINUqEIPcAPNYQB1qG79SafrRAvTqcjtEHTn2wXh2ZGu3f1T+SCK0ZD3xx1ML8502ENzXjvq+dEmi4kknqmPudkb6k= \ No newline at end of file diff --git a/bin/ci b/bin/ci index dccd8971bfdd..4b6f258c6bc1 100755 --- a/bin/ci +++ b/bin/ci @@ -5,6 +5,28 @@ fail() { exit 1 } +on_deploy() { + if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then + if [ "${DEPLOY}" = "true" ]; then + echo "${@}" + eval "${@}" + return $? + else + return 0 + fi + fi +} + +on_tag() { + if [ -n "$CURRENT_TAG" ]; then + echo "${@}" + eval "${@}" + return $? + else + return 0 + fi +} + fail_on_error() { "${@}" @@ -57,6 +79,69 @@ on_osx() { prepare_system() { on_osx brew update + on_deploy sudo pip install awscli +} + +build() { + with_build_env 'make std_spec clean' + with_build_env 'make crystal std_spec compiler_spec doc' + with_build_env 'find samples -name "*.cr" | xargs -L 1 ./bin/crystal compile --no-codegen' + with_build_env './bin/crystal tool format --check' +} + +deploy() { + export CURRENT_TAG=`git describe --tags --exact-match 2> /dev/null` + export GIT_VERSION=`git describe --tags --long --always 2>/dev/null` + on_deploy 'echo $GIT_VERSION > doc/revision.txt' + + on_deploy aws s3 sync doc/ s3://crystal-api/api/$TRAVIS_BRANCH + + on_deploy on_tag aws s3 sync doc/ s3://crystal-api/api/$CURRENT_TAG + cat - > .aws-config <