| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | set -e -x | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function publishRepo { | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |   COMPONENT=$1 | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  |   ARTIFACTS_DIR=$2 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |   BUILD_REPO="${COMPONENT}-builds" | 
					
						
							|  |  |  |   REPO_DIR="tmp/${BUILD_REPO}" | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |   echo "Pushing build artifacts to angular/${BUILD_REPO}" | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # 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 && \
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |     git fetch origin master && \
 | 
					
						
							|  |  |  |     git checkout origin/master && \
 | 
					
						
							|  |  |  |     git checkout -b master | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  |   ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   # copy over build artifacts into the repo directory | 
					
						
							|  |  |  |   rm -rf $REPO_DIR/* | 
					
						
							|  |  |  |   cp -R $ARTIFACTS_DIR/* $REPO_DIR/ | 
					
						
							| 
									
										
										
										
											2016-05-25 15:37:40 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |   # Replace $$ANGULAR_VESION$$ with the build version. | 
					
						
							|  |  |  |   BUILD_VER="2.0.0-${SHORT_SHA}" | 
					
						
							| 
									
										
										
										
											2016-05-12 13:58:42 -07:00
										 |  |  |   if [[ ${TRAVIS} ]]; then | 
					
						
							|  |  |  |     find $REPO_DIR/ -type f -name package.json -print0 | xargs -0 sed -i "s/\\\$\\\$ANGULAR_VERSION\\\$\\\$/${BUILD_VER}/g" | 
					
						
							| 
									
										
										
										
											2016-05-12 16:49:03 -07:00
										 |  |  |     UMD=$(find $REPO_DIR/ -type f -name "*umd.js" -print0) | 
					
						
							|  |  |  |     if [[ ${UMD} ]]; then | 
					
						
							|  |  |  |       sed -i "s/\\\$\\\$ANGULAR_VERSION\\\$\\\$/${BUILD_VER}/g" ${UMD} | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2016-05-12 13:58:42 -07:00
										 |  |  |   else | 
					
						
							|  |  |  |     find $REPO_DIR/ -type f -name package.json -print0 | xargs -0 sed -i '' "s/\\\$\\\$ANGULAR_VERSION\\\$\\\$/${BUILD_VER}/g" | 
					
						
							|  |  |  |     find $REPO_DIR/ -type f -name "*umd.js" -print0 | xargs -0 sed -i '' "s/\\\$\\\$ANGULAR_VERSION\\\$\\\$/${BUILD_VER}/g" | 
					
						
							|  |  |  |   fi | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  |   echo `date` > $REPO_DIR/BUILD_INFO | 
					
						
							|  |  |  |   echo $SHA >> $REPO_DIR/BUILD_INFO | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ( | 
					
						
							|  |  |  |     cd $REPO_DIR && \
 | 
					
						
							| 
									
										
										
										
											2015-11-16 18:14:14 -08:00
										 |  |  |     git config credential.helper "store --file=.git/credentials" && \
 | 
					
						
							|  |  |  |     echo "https://${GITHUB_TOKEN_ANGULAR}:@github.com" > .git/credentials && \
 | 
					
						
							|  |  |  |     git config user.name "${COMMITTER_USER_NAME}" && \
 | 
					
						
							|  |  |  |     git config user.email "${COMMITTER_USER_EMAIL}" && \
 | 
					
						
							| 
									
										
										
										
											2015-11-17 14:56:51 -08:00
										 |  |  |     git add --all && \
 | 
					
						
							|  |  |  |     git commit -m "${COMMIT_MSG}" && \
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |     git push origin master && \
 | 
					
						
							|  |  |  |     git tag "${BUILD_VER}" && \
 | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  |     git push origin --tags | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  | # Publish all individual packages from packages-dist. | 
					
						
							| 
									
										
										
										
											2016-03-04 18:00:16 -08:00
										 |  |  | if [[ "$TRAVIS_REPO_SLUG" == "angular/angular" && \
 | 
					
						
							|  |  |  |       "$TRAVIS_PULL_REQUEST" == "false" && \
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |       "$CI_MODE" == "e2e" ]]; then | 
					
						
							| 
									
										
										
										
											2016-06-13 17:14:35 -07:00
										 |  |  |   for dir in dist/packages-dist/*/ dist/tools/@angular/tsc-wrapped | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |   do | 
					
						
							|  |  |  |     COMPONENT="$(basename ${dir})" | 
					
						
							| 
									
										
										
										
											2016-03-04 19:16:12 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |     # Replace _ with - in component name. | 
					
						
							|  |  |  |     COMPONENT="${COMPONENT//_/-}" | 
					
						
							|  |  |  |     JS_BUILD_ARTIFACTS_DIR="${dir}" | 
					
						
							| 
									
										
										
										
											2016-03-04 19:16:12 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |     REPO_URL="https://github.com/angular/${COMPONENT}-builds.git" | 
					
						
							|  |  |  |     # Use the below URL for testing when using SSH authentication | 
					
						
							|  |  |  |     # REPO_URL="git@github.com:angular/${COMPONENT}-builds.git" | 
					
						
							| 
									
										
										
										
											2016-03-04 19:16:12 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |     SHA=`git rev-parse HEAD` | 
					
						
							|  |  |  |     SHORT_SHA=`git rev-parse --short HEAD` | 
					
						
							|  |  |  |     COMMIT_MSG=`git log --oneline | head -n1` | 
					
						
							|  |  |  |     COMMITTER_USER_NAME=`git --no-pager show -s --format='%cN' HEAD` | 
					
						
							|  |  |  |     COMMITTER_USER_EMAIL=`git --no-pager show -s --format='%cE' HEAD` | 
					
						
							| 
									
										
										
										
											2016-03-04 19:16:12 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-09 17:26:51 -07:00
										 |  |  |     publishRepo "${COMPONENT}" "${JS_BUILD_ARTIFACTS_DIR}" | 
					
						
							|  |  |  |   done | 
					
						
							| 
									
										
										
										
											2015-11-17 22:56:41 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  |   echo "Finished publishing build artifacts" | 
					
						
							| 
									
										
										
										
											2016-03-04 19:16:12 -08:00
										 |  |  | else | 
					
						
							|  |  |  |   echo "Not building the upstream/master branch, build artifacts won't be published." | 
					
						
							| 
									
										
										
										
											2015-11-09 15:25:00 -08:00
										 |  |  | fi |