From 406ace9b251aa99b690037782ebfd72eca87b3d9 Mon Sep 17 00:00:00 2001 From: Yegor Jbanov Date: Mon, 9 Nov 2015 15:25:00 -0800 Subject: [PATCH] chore(build): deploy build artifacts to build branches - use orphan branch - use upstream .gitignore - use short SHA in commit messages - tag commits with source SHA Closes #5203 --- .travis.yml | 1 + scripts/ci/presubmit-queue-setup.sh | 10 +++-- scripts/ci/publish-build-artifacts.sh | 60 +++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100755 scripts/ci/publish-build-artifacts.sh diff --git a/.travis.yml b/.travis.yml index 579cbfaefb..a92ea10743 100644 --- a/.travis.yml +++ b/.travis.yml @@ -90,6 +90,7 @@ after_script: - node tools/analytics/build-analytics start ci after_script - ./scripts/ci/print-logs.sh - ./scripts/ci/after-script.sh +- ./scripts/ci/publish-build-artifacts.sh - node tools/analytics/build-analytics success ci after_script - if [[ $TRAVIS_TEST_RESULT -eq 0 ]]; then node tools/analytics/build-analytics success ci job; else node tools/analytics/build-analytics error ci job; fi diff --git a/scripts/ci/presubmit-queue-setup.sh b/scripts/ci/presubmit-queue-setup.sh index 757d6a3c01..dbeaaf5622 100755 --- a/scripts/ci/presubmit-queue-setup.sh +++ b/scripts/ci/presubmit-queue-setup.sh @@ -2,7 +2,7 @@ set -e -o pipefail if [ "$TRAVIS_REPO_SLUG" = "angular/angular" ]; then - if [[ $TRAVIS_BRANCH == "presubmit-"* ]]; then + if [[ $TRAVIS_BRANCH == "presubmit-"* || $MODE == "build_only" ]]; then echo '*********************' echo '** PRESUBMIT SETUP **' @@ -14,8 +14,10 @@ if [ "$TRAVIS_REPO_SLUG" = "angular/angular" ]; then git config user.name "`git --no-pager show -s --format='%cN' HEAD`" git config user.email "`git --no-pager show -s --format='%cE' HEAD`" - git remote add upstream https://github.com/angular/angular.git - git fetch upstream master - git rebase upstream/master + if [[ $TRAVIS_BRANCH == "presubmit-"* ]]; then + git remote add upstream https://github.com/angular/angular.git + git fetch upstream master + git rebase upstream/master + fi fi fi diff --git a/scripts/ci/publish-build-artifacts.sh b/scripts/ci/publish-build-artifacts.sh new file mode 100755 index 0000000000..39ad33e72f --- /dev/null +++ b/scripts/ci/publish-build-artifacts.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e -x + +DART_BUILD_ARTIFACTS_DIR="dist/dart/angular2" +JS_BUILD_ARTIFACTS_DIR="dist/js/prod/es5/angular2" + +DART_BUILD_BRANCH="builds-dart" +JS_BUILD_BRANCH="builds-js" + +REPO_URL="https://github.com/angular/angular.git" +# Use the below URL for testing when using SSH authentication +# REPO_URL="git@github.com:angular/angular.git" + +SHA=`git rev-parse HEAD` +SHORT_SHA=`git rev-parse --short HEAD` +COMMIT_MSG=`git log --oneline | head -n1` + +function publishRepo { + LANG=$1 + ARTIFACTS_DIR=$2 + + BUILD_BRANCH="builds-${LANG}" + REPO_DIR="tmp/${BUILD_BRANCH}" + + echo "Pushing build artifacts to angular/$BUILD_BRANCH" + + # create local repo folder and clone build repo into it + rm -rf $REPO_DIR + mkdir -p $REPO_DIR + ( + cd $REPO_DIR && \ + git init && \ + git remote add origin $REPO_URL && \ + git fetch origin $BUILD_BRANCH && \ + git checkout origin/$BUILD_BRANCH && \ + git checkout -b $BUILD_BRANCH + ) + + # copy over build artifacts into the repo directory + rm -rf $REPO_DIR/* + cp -R $ARTIFACTS_DIR/* $REPO_DIR/ + cp .gitignore $REPO_DIR/ + echo `date` > $REPO_DIR/BUILD_INFO + echo $SHA >> $REPO_DIR/BUILD_INFO + + ( + cd $REPO_DIR && \ + git add --all && \ + git commit -m "${COMMIT_MSG}" && \ + git push origin $BUILD_BRANCH && \ + git tag "2.0.0-build.${SHORT_SHA}.${LANG}" && \ + git push origin --tags + ) +} + +if [ "$TRAVIS_REPO_SLUG" = "angular/angular" && "$MODE" == "build_only" ]; then + publishRepo "js" "${JS_BUILD_ARTIFACTS_DIR}" + publishRepo "dart" "${DART_BUILD_ARTIFACTS_DIR}" + echo "Finished publishing build artifacts" +fi