2017-03-02 03:22:24 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -u -e -o pipefail
|
|
|
|
|
|
|
|
# Setup environment
|
2017-03-05 04:49:10 -05:00
|
|
|
readonly thisDir=$(cd $(dirname $0); pwd)
|
|
|
|
source ${thisDir}/_travis-fold.sh
|
|
|
|
|
|
|
|
|
|
|
|
# If the previous commands in the `script` section of .travis.yaml failed, then abort.
|
|
|
|
# The variable is not set in early stages of the build, so we default to 0 there.
|
|
|
|
# https://docs.travis-ci.com/user/environment-variables/
|
|
|
|
if [[ ${TRAVIS_TEST_RESULT=0} == 1 ]]; then
|
|
|
|
exit 1;
|
|
|
|
fi
|
2017-03-02 03:22:24 -05:00
|
|
|
|
|
|
|
|
2017-02-06 13:40:28 -05:00
|
|
|
# Don't deploy if not running against angular/angular
|
2017-03-02 03:22:24 -05:00
|
|
|
# TODO(i): because we don't let deploy to run outside of angular/angular folks can't use their
|
|
|
|
# private travis build to deploy anywhere. This is likely ok, but this means that @alexeagle's
|
|
|
|
# fancy setup to publish ES2015 packages to github -build repos no longer works. This is ok
|
2017-03-05 04:49:10 -05:00
|
|
|
# since with flat modules we'll have this feature built-in. We should still go and remove
|
2017-03-02 03:22:24 -05:00
|
|
|
# stuff that Alex put in for this from publish-build-artifacts.sh
|
2017-02-06 13:40:28 -05:00
|
|
|
if [[ ${TRAVIS_REPO_SLUG} != "angular/angular" ]]; then
|
|
|
|
echo "Skipping deploy because this is not angular/angular."
|
2017-03-02 03:22:24 -05:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
case ${CI_MODE} in
|
|
|
|
e2e)
|
2017-02-06 13:40:28 -05:00
|
|
|
# Don't deploy if this is a PR build
|
|
|
|
if [[ ${TRAVIS_PULL_REQUEST} != "false" ]]; then
|
|
|
|
echo "Skipping deploy because this is a PR build."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-03-02 03:22:24 -05:00
|
|
|
travisFoldStart "deploy.packages"
|
2017-03-05 04:49:10 -05:00
|
|
|
${thisDir}/publish-build-artifacts.sh
|
2017-03-02 03:22:24 -05:00
|
|
|
travisFoldEnd "deploy.packages"
|
|
|
|
;;
|
|
|
|
aio)
|
2017-02-06 13:40:28 -05:00
|
|
|
# Don't deploy if this build is not for master
|
|
|
|
if [[ ${TRAVIS_BRANCH} != "master" ]]; then
|
|
|
|
echo "Skipping deploy because this build is not for master."
|
|
|
|
exit 0
|
2017-03-02 03:22:24 -05:00
|
|
|
fi
|
2017-02-06 13:40:28 -05:00
|
|
|
|
|
|
|
travisFoldStart "deploy.aio"
|
|
|
|
(
|
|
|
|
cd ${TRAVIS_BUILD_DIR}/aio
|
|
|
|
|
|
|
|
if [[ $TRAVIS_PULL_REQUEST != "false" ]]; then
|
|
|
|
# This is a PR: deploy a snapshot for previewing
|
|
|
|
travisFoldStart "deploy.aio.pr-preview"
|
2017-03-06 15:31:43 -05:00
|
|
|
# Only deploy if this PR has touched relevant files.
|
2017-03-07 04:39:37 -05:00
|
|
|
readonly AIO_CHANGED_FILES_COUNT=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep ^aio/ | wc -l)
|
2017-03-06 15:31:43 -05:00
|
|
|
if [[ AIO_CHANGED_FILES_COUNT -eq 0 ]]; then
|
|
|
|
echo "Skipping deploy because this PR did not touch any files inside 'aio/'."
|
|
|
|
else
|
2017-03-07 04:39:37 -05:00
|
|
|
# Only deploy if this PR meets certain preconditions.
|
|
|
|
readonly AIO_PREVERIFY_EXIT_CODE=$(./aio-builds-setup/scripts/travis-preverify-pr.sh && echo 0 || echo $?)
|
|
|
|
case $AIO_PREVERIFY_EXIT_CODE in
|
|
|
|
2)
|
|
|
|
# An error occurred: Fail the build
|
|
|
|
exit 1;
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
# Preconditions not met: Skip deploy
|
|
|
|
echo "Skipping deploy because this PR did not meet the preconditions."
|
|
|
|
;;
|
|
|
|
0)
|
|
|
|
# Preconditions met: Deploy
|
|
|
|
yarn run deploy-preview
|
|
|
|
;;
|
|
|
|
esac
|
2017-03-06 15:31:43 -05:00
|
|
|
fi
|
2017-02-06 13:40:28 -05:00
|
|
|
travisFoldEnd "deploy.aio.pr-preview"
|
|
|
|
else
|
|
|
|
# This is upstream master: Deploy to staging
|
|
|
|
travisFoldStart "deploy.aio.staging"
|
|
|
|
yarn run deploy-staging
|
|
|
|
travisFoldEnd "deploy.aio.staging"
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
travisFoldEnd "deploy.aio"
|
2017-03-02 03:22:24 -05:00
|
|
|
;;
|
|
|
|
esac
|