diff options
| author | Tobias Bosch | 2014-01-06 12:19:51 -0800 | 
|---|---|---|
| committer | Tobias Bosch | 2014-01-06 12:27:54 -0800 | 
| commit | 5dc27959d5c0e45cc0cc6133a9ef676cc15d44bd (patch) | |
| tree | ecc31ec61ff67169774d529d487f819616638a01 /scripts/bower | |
| parent | 4c21355940a98c7236a33d1b5e86d6cd3cf562cb (diff) | |
| download | angular.js-5dc27959d5c0e45cc0cc6133a9ef676cc15d44bd.tar.bz2 | |
chore(build): refactor build scripts in prepare/publish phase
Refactored all scripts so that they are divided into a `prepare`
and a `publish` phase. By this we can build, test, tag, commit
everything first. Only if all of this is ok we start pushing
to Github. By this we keep Github consistent even in error cases.
Extracted include script `/scripts/utils.inc`:
- parse and validate named arguments in the style
  `--name=value`
- proxy git command and deactivate `git push` based on
  command option `--git_push_dry_run=true`
  (will be inherited to child scripts)
- enable/disable bash debug mode by command option
  `--verbose=true`
- dispatch to functions based on command option
  `--action=...`
- helper functions for dealing with json files
Diffstat (limited to 'scripts/bower')
| -rw-r--r-- | scripts/bower/README.md | 15 | ||||
| -rwxr-xr-x | scripts/bower/publish.sh | 173 | 
2 files changed, 93 insertions, 95 deletions
| diff --git a/scripts/bower/README.md b/scripts/bower/README.md deleted file mode 100644 index 06ba9d61..00000000 --- a/scripts/bower/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Angular Bower Script - -Script for updating the Angular bower repos from current local build. - -## Instructions - -`grunt package`: Build angular locally - -```shell -./publish.sh -``` - -## License -MIT - diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index a2bf3683..ad77aadc 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -1,88 +1,101 @@  #!/bin/bash +# Script for updating the Angular bower repos from current local build. +  echo "#################################"  echo "#### Update bower ###############"  echo "#################################" -# Enable tracing and exit on first failure -set -xe -# Normalize working dir to script dir -cd `dirname $0` - -SCRIPT_DIR=`pwd` -TMP_DIR=../../tmp -BUILD_DIR=../../build -NEW_VERSION=`cat $BUILD_DIR/version.txt` - -REPOS=( -  angular           \ -  angular-animate   \ -  angular-cookies   \ -  angular-i18n      \ -  angular-loader    \ -  angular-mocks     \ -  angular-route     \ -  angular-resource  \ -  angular-sanitize  \ -  angular-scenario  \ -  angular-touch     \ +ARG_DEFS=( +  "--action=(prepare|publish)"  ) -# -# clone repos -# -for repo in "${REPOS[@]}" -do -  echo "-- Cloning bower-$repo" -  git clone git@github.com:angular/bower-$repo.git $TMP_DIR/bower-$repo -done - - -# -# move the files from the build -# - -for repo in "${REPOS[@]}" -do -  if [ -f $BUILD_DIR/$repo.js ] # ignore i18l -    then -      echo "-- Updating files in bower-$repo" -      cd $TMP_DIR/bower-$repo -      git reset --hard HEAD -      git checkout master -      git fetch --all -      git reset --hard origin/master -      cd $SCRIPT_DIR -      cp $BUILD_DIR/$repo.* $TMP_DIR/bower-$repo/ -  fi -done - -# move i18n files -cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/ - -# move csp.css -cp $BUILD_DIR/angular-csp.css $TMP_DIR/bower-angular - - -# -# update bower.json -# tag each repo -# - -for repo in "${REPOS[@]}" -do -  echo "-- Updating version in bower-$repo to $NEW_VERSION" -  cd $TMP_DIR/bower-$repo -  sed -i .tmp -E 's/"(version)":[ ]*".*"/"\1": "'$NEW_VERSION'"/g' bower.json -  sed -i .tmp -E 's/"(angular.*)":[ ]*".*"/"\1": "'$NEW_VERSION'"/g' bower.json -  # delete tmp files -  rm *.tmp -  git add -A - -  echo "-- Committing, tagging and pushing bower-$repo" -  git commit -m "v$NEW_VERSION" -  git tag v$NEW_VERSION -  git push origin master -  git push origin v$NEW_VERSION -  cd $SCRIPT_DIR -done +function init { +  TMP_DIR=$(resolveDir ../../tmp) +  BUILD_DIR=$(resolveDir ../../build) +  NEW_VERSION=$(cat $BUILD_DIR/version.txt) +  REPOS=( +    angular +    angular-animate +    angular-cookies +    angular-i18n +    angular-loader +    angular-mocks +    angular-route +    angular-resource +    angular-sanitize +    angular-scenario +    angular-touch +  ) +} + + +function prepare { +  # +  # clone repos +  # +  for repo in "${REPOS[@]}" +  do +    echo "-- Cloning bower-$repo" +    git clone git@github.com:angular/bower-$repo.git $TMP_DIR/bower-$repo +  done + + +  # +  # move the files from the build +  # + +  for repo in "${REPOS[@]}" +  do +    if [ -f $BUILD_DIR/$repo.js ] # ignore i18l +      then +        echo "-- Updating files in bower-$repo" +        cd $TMP_DIR/bower-$repo +        git reset --hard HEAD +        git checkout master +        git fetch --all +        git reset --hard origin/master +        cd $SCRIPT_DIR +        cp $BUILD_DIR/$repo.* $TMP_DIR/bower-$repo/ +    fi +  done + +  # move i18n files +  cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/ + +  # move csp.css +  cp $BUILD_DIR/angular-csp.css $TMP_DIR/bower-angular + + +  # +  # update bower.json +  # tag each repo +  # +  for repo in "${REPOS[@]}" +  do +    echo "-- Updating version in bower-$repo to $NEW_VERSION" +    cd $TMP_DIR/bower-$repo +    replaceJsonProp "bower.json" "version" ".*" "$NEW_VERSION" +    replaceJsonProp "bower.json" "angular.*" ".*" "$NEW_VERSION" + +    git add -A + +    echo "-- Committing and tagging bower-$repo" +    git commit -m "v$NEW_VERSION" +    git tag v$NEW_VERSION +    cd $SCRIPT_DIR +  done +} + +function publish { +  for repo in "${REPOS[@]}" +  do +    echo "-- Pushing bower-$repo" +    cd $TMP_DIR/bower-$repo +    git push origin master +    git push origin v$NEW_VERSION +    cd $SCRIPT_DIR +  done +} + +source $(dirname $0)/../utils.inc | 
