|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Script for updating the Angular bower repos from current local build. |
| 4 | + |
| 5 | +echo "#################################" |
| 6 | +echo "#### Update bower ###############" |
| 7 | +echo "#################################" |
| 8 | + |
| 9 | +ARG_DEFS=( |
| 10 | + "--action=(prepare|publish)" |
| 11 | + # the version number of the release. |
| 12 | + # e.g. 1.2.12 or 1.2.12-rc.1 |
| 13 | + "--version-number=([0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?)" |
| 14 | +) |
| 15 | + |
| 16 | +function init { |
| 17 | + BOWER_ANGULAR_DIR=$(resolveDir ../../bower-angular) |
| 18 | + BUILD_DIR=$(resolveDir ../../build) |
| 19 | + NEW_VERSION=$VERSION_NUMBER |
| 20 | + if [ -z $NEW_VERSION ] |
| 21 | + then |
| 22 | + NEW_VERSION=$(cat $BUILD_DIR/version.txt) |
| 23 | + fi |
| 24 | + # get the npm dist-tag from a custom property (distTag) in package.json |
| 25 | +# DIST_TAG=$(readJsonProp "package.json" "distTag") |
| 26 | +} |
| 27 | + |
| 28 | + |
| 29 | +function prepare { |
| 30 | + # |
| 31 | + # move the files from the build |
| 32 | + # |
| 33 | + if [ -f $BUILD_DIR/angular.js ] # ignore i18l |
| 34 | + then |
| 35 | + echo "-- Updating files in bower-angular" |
| 36 | + cp $BUILD_DIR/angular.* $BOWER_ANGULAR_DIR |
| 37 | + fi |
| 38 | + |
| 39 | + # move i18n files |
| 40 | +# cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/ |
| 41 | + |
| 42 | + # move csp.css |
| 43 | + cp $BUILD_DIR/angular-csp.css $BOWER_ANGULAR_DIR |
| 44 | + |
| 45 | + |
| 46 | + # |
| 47 | + # Run local precommit script if there is one |
| 48 | + # |
| 49 | + if [ -f $BOWER_ANGULAR_DIR/precommit.sh ] |
| 50 | + then |
| 51 | + echo "-- Running precommit.sh script for bower-angular" |
| 52 | + cd $BOWER_ANGULAR_DIR |
| 53 | + ./precommit.sh |
| 54 | + cd $SCRIPT_DIR |
| 55 | + fi |
| 56 | + |
| 57 | + |
| 58 | + # |
| 59 | + # update bower.json |
| 60 | + # tag each repo |
| 61 | + # |
| 62 | + echo "-- Updating version in bower-angular to $NEW_VERSION" |
| 63 | + cd $BOWER_ANGULAR_DIR |
| 64 | + replaceJsonProp "bower.json" "version" ".*" "$NEW_VERSION" |
| 65 | + replaceJsonProp "bower.json" "angular.*" ".*" "$NEW_VERSION" |
| 66 | + replaceJsonProp "package.json" "version" ".*" "$NEW_VERSION" |
| 67 | + replaceJsonProp "package.json" "angular.*" ".*" "$NEW_VERSION" |
| 68 | + |
| 69 | + git add -A |
| 70 | + |
| 71 | + echo "-- Committing and tagging bower-angular" |
| 72 | + git commit -m "v$NEW_VERSION" |
| 73 | + git tag v$NEW_VERSION |
| 74 | + cd $SCRIPT_DIR |
| 75 | +} |
| 76 | + |
| 77 | +function publish { |
| 78 | + echo "-- Pushing bower-angular" |
| 79 | + cd $BOWER_ANGULAR_DIR |
| 80 | + git push origin master |
| 81 | + git push origin v$NEW_VERSION |
| 82 | + |
| 83 | + # don't publish every build to npm |
| 84 | +# if [ "${NEW_VERSION/+sha}" = "$NEW_VERSION" ] ; then |
| 85 | +# echo "-- Publishing to npm as $DIST_TAG" |
| 86 | +# npm publish --tag=$DIST_TAG |
| 87 | +# fi |
| 88 | + |
| 89 | + cd $SCRIPT_DIR |
| 90 | +} |
| 91 | + |
| 92 | +source $(dirname $0)/../utils.inc |
0 commit comments