diff --git a/aio/.firebaserc b/aio/.firebaserc deleted file mode 100644 index a44c716187..0000000000 --- a/aio/.firebaserc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "projects": { - "staging": "aio-staging" - } -} diff --git a/aio/package.json b/aio/package.json index b9ff0cfb9c..654ca73374 100644 --- a/aio/package.json +++ b/aio/package.json @@ -20,7 +20,8 @@ "example-e2e": "node ./tools/examples/run-example-e2e", "example-lint": "tslint -c \"content/examples/tslint.json\" \"content/examples/**/*.ts\" -e \"content/examples/styleguide/**/*.avoid.ts\"", "deploy-preview": "scripts/deploy-preview.sh", - "deploy-staging": "scripts/deploy-staging.sh", + "deploy-staging": "scripts/deploy-to-firebase.sh staging", + "deploy-production": "scripts/deploy-to-firebase.sh production", "check-env": "node ../tools/check-environment.js", "predocs": "rimraf src/generated/{docs,*.json}", "docs": "dgeni ./tools/transforms/angular.io-package", diff --git a/aio/scripts/deploy-staging.sh b/aio/scripts/deploy-staging.sh deleted file mode 100755 index 15943643ad..0000000000 --- a/aio/scripts/deploy-staging.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -# WARNING: FIREBASE_TOKEN should NOT be printed. -set +x -eu -o pipefail - - -FIREBASE_PROJECT_ID=aio-staging -DEPLOYED_URL=https://$FIREBASE_PROJECT_ID.firebaseapp.com - -( - cd "`dirname $0`/.." - - # Build the app - yarn build - - # Deploy to staging - firebase use "$FIREBASE_PROJECT_ID" --token "$FIREBASE_TOKEN" - firebase deploy --message "Commit: $TRAVIS_COMMIT" --non-interactive --token "$FIREBASE_TOKEN" - - # Run PWA-score tests - # TODO(gkalpak): Figure out why this fails and re-enable. - sleep 10 - yarn test-pwa-score -- "$DEPLOYED_URL" "$MIN_PWA_SCORE" "$PWA_RESULTS_LOG" || true -) diff --git a/aio/scripts/deploy-to-firebase.sh b/aio/scripts/deploy-to-firebase.sh new file mode 100644 index 0000000000..36f14f288d --- /dev/null +++ b/aio/scripts/deploy-to-firebase.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# WARNING: FIREBASE_TOKEN should NOT be printed. +set +x -eu -o pipefail + + +readonly deployEnv=$1 + +case $deployEnv in + staging) + readonly projectId=aio-staging + readonly deployedUrl=https://$projectId.firebaseapp.com/ + readonly firebaseToken=$FIREBASE_TOKEN + ;; + production) + readonly projectId=angular-io + readonly deployedUrl=https://angular.io/ + readonly firebaseToken=$FIREBASE_TOKEN + ;; + *) + echo "Unknown deployment environment ('$deployEnv'). Expected 'staging' or 'production'." + exit 1 + ;; +esac + +( + cd "`dirname $0`/.." + + # Build the app + yarn build + + # Deploy to Firebase + firebase use "$projectId" --token "$firebaseToken" + firebase deploy --message "Commit: $TRAVIS_COMMIT" --non-interactive --token "$firebaseToken" + + # Run PWA-score tests + # TODO(gkalpak): Figure out why this fails and re-enable. + yarn test-pwa-score -- "$deployedUrl" "$MIN_PWA_SCORE" "$PWA_RESULTS_LOG" || true +) diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index ff089d0c20..e572aadf3e 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -44,10 +44,10 @@ if [[ ${CI_MODE:-} == "aio" ]]; then cd "`dirname $0`/../../aio" yarn build - # If this is a PR for angular/angular@master, deploy a snapshot for previewing early - # (if preconditions are met) regardless of the test outcome. + # If this is a PR for angular/angular@master or angular/angular@, deploy a + # snapshot for previewing early (if preconditions are met) regardless of the test outcome. if [[ ${TRAVIS_REPO_SLUG} == "angular/angular" ]] && - [[ ${TRAVIS_BRANCH} == "master" ]] && + ([[ $TRAVIS_BRANCH == "master" ]] || [[ $TRAVIS_BRANCH == $STABLE_BRANCH ]]) && [[ $TRAVIS_PULL_REQUEST != "false" ]]; then travisFoldStart "deploy.aio.pr-preview" yarn deploy-preview -- --skip-build diff --git a/scripts/ci/deploy.sh b/scripts/ci/deploy.sh index b06e4d07ab..c5a85f576b 100755 --- a/scripts/ci/deploy.sh +++ b/scripts/ci/deploy.sh @@ -40,24 +40,33 @@ case ${CI_MODE} in travisFoldEnd "deploy.packages" ;; aio) - # 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 - fi + # Only deploy if this not a PR. PRs are deployed early in `build.sh`. + if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then - travisFoldStart "deploy.aio" - ( - cd ${TRAVIS_BUILD_DIR}/aio - - # Only deploy if this not a PR. PRs are deployed early in `build.sh`. - if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then - # This is upstream master: Deploy to staging - travisFoldStart "deploy.aio.staging" - yarn deploy-staging - travisFoldEnd "deploy.aio.staging" + # Don't deploy if this build is not for master or the stable branch. + if [[ $TRAVIS_BRANCH != "master" ]] && [[ $TRAVIS_BRANCH != $STABLE_BRANCH ]]; then + echo "Skipping deploy because this build is not for master or the stable branch ($STABLE_BRANCH)." + exit 0 fi - ) - travisFoldEnd "deploy.aio" + + travisFoldStart "deploy.aio" + ( + cd ${TRAVIS_BUILD_DIR}/aio + + if [[ $TRAVIS_BRANCH == $STABLE_BRANCH ]]; then + # This is upstream : Deploy to production. + travisFoldStart "deploy.aio.production" + yarn deploy-production + travisFoldEnd "deploy.aio.production" + else + # This is upstream master: Deploy to staging. + travisFoldStart "deploy.aio.staging" + yarn deploy-staging + travisFoldEnd "deploy.aio.staging" + fi + ) + travisFoldEnd "deploy.aio" + + fi ;; esac diff --git a/scripts/ci/env.sh b/scripts/ci/env.sh index 600d275cff..e58b16aef1 100755 --- a/scripts/ci/env.sh +++ b/scripts/ci/env.sh @@ -59,6 +59,10 @@ if [[ ${TRAVIS:-} ]]; then setEnvVar KARMA_JS_BROWSERS `node -e "console.log(require('/home/travis/build/angular/angular/browser-providers.conf').browserstackAliases.CI_OPTIONAL.join(','))"` ;; aio) + # Determine the current stable branch. + readonly versionRe="^\s*([0-9]+\.[0-9]+)\.[0-9]+.*$" + setEnvVar STABLE_BRANCH `npm info @angular/core dist-tags.latest | sed -r "s/$versionRe/\1.x/"` + setEnvVar MIN_PWA_SCORE 95 ;; esac