Skip to content

Commit

Permalink
Showing 2 changed files with 53 additions and 33 deletions.
39 changes: 6 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -7,24 +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
- if [ "$ARCH" = "x86_64" ]; then sudo pip install awscli; fi
install: bin/ci prepare_build
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 compile --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:
@@ -40,28 +38,3 @@ env:
global:
- AWS_ACCESS_KEY_ID=AKIAIRL4BWFPN7P54TBQ
- secure: Zd/tZVmV2dRMao9z+ky5BywSKuWOF3MiKsZetwd1upZ+uj9qzfbOZMnWFW9dlA+Co4MyYqP/I6ADzRpoKLINUqEIPcAPNYQB1qG79SafrRAvTqcjtEHTn2wXh2ZGu3f1T+SCK0ZD3xx1ML8502ENzXjvq+dEmi4kknqmPudkb6k=
deploy:
- provider: s3
access_key_id: AKIAIRL4BWFPN7P54TBQ
secret_access_key:
secure: XbirZ4olRckszhip5ljHl556WcgohwrTdI3e2uproJBUYLU/kLwvusATL38TAWeMNPaIzZMHHp+Q5EPDfsiCuXuLHlhAoVVSM3K2UGJ43H5iN2srSf15dCsVgeJmffwW1Pceew/y4wFbp6INc1XfwKuE8+aXIyH7WTfKrqQv/w8=
bucket: crystal-api
local_dir: doc
upload-dir: api/master
on:
branch: master
condition: $ARCH = x86_64
skip_cleanup: true
after_success: |
if [ "$ARCH" = "x86_64" ]
then
CURRENT_TAG=`git describe --tags --exact-match 2> /dev/null`
if [ "$CURRENT_TAG" != "" ]
then
echo "deploying docs to s3 for tag $CURRENT_TAG"
aws s3 sync doc/ s3://crystal-api/api/$CURRENT_TAG
aws s3api put-object --bucket crystal-api --key api/index.html --website-redirect-location /api/$CURRENT_TAG
else
echo "deploying docs to s3 for tag skipped due to missing tag"
fi
fi
47 changes: 47 additions & 0 deletions bin/ci
Original file line number Diff line number Diff line change
@@ -5,6 +5,25 @@ fail() {
exit 1
}

on_deploy() {
if [ -z "$TRAVIS_PULL_REQUEST" -a "$DEPLOY" = "true" ]; then
eval "${@}"
return $?
else
return 0
fi
}

on_tag() {
if [ -n "$CURRENT_TAG" ]; then
echo "${@}"
eval "${@}"
return $?
else
return 0
fi
}

fail_on_error() {
"${@}"

@@ -57,9 +76,29 @@ 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 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
on_deploy on_tag aws s3api put-object --bucket crystal-api --key api/index.html --website-redirect-location /api/$CURRENT_TAG
}

prepare_build() {
export CURRENT_TAG=`git describe --tags --exact-match 2> /dev/null`

on_linux verify_linux_environment

on_linux docker pull "jhass/crystal-build-$ARCH"
@@ -98,6 +137,8 @@ usage() {
echo -e "Commands:"
echo -e " prepare_system setup any necessaries repositories etc."
echo -e " prepare_build download and extract any dependencies needed for the build"
echo -e " build run specs, build crystal, run format check, build samples, build the docs"
echo -e " deploy deploy the docs"
echo -e " with_build_env command run command in the build environment"
echo -e " help display this"
echo -e ""
@@ -116,6 +157,12 @@ case $command in
target_command="${@}"
with_build_env "$target_command"
;;
build)
build
;;
deploy)
deploy
;;
-h|--help|help)
usage
;;

0 comments on commit e28717a

Please sign in to comment.