diff options
| author | Tobias Bosch | 2013-12-13 12:49:42 -0800 |
|---|---|---|
| committer | Tobias Bosch | 2013-12-13 12:51:13 -0800 |
| commit | 8c10db384727643265b1550543011d3193dfe557 (patch) | |
| tree | 836f583f1618e6dc1814afc6ee9265957402b74a | |
| parent | 03088d60109582fa5e966ad8425b3de9d9152b6a (diff) | |
| download | angular.js-8c10db384727643265b1550543011d3193dfe557.tar.bz2 | |
chore(build): automate cutting a release, publishing to bower and to code.angular.js
| -rw-r--r-- | Gruntfile.js | 10 | ||||
| -rw-r--r--[-rwxr-xr-x] | jenkins_build.sh | 0 | ||||
| -rw-r--r-- | lib/grunt/utils.js | 9 | ||||
| -rw-r--r-- | package.json | 1 | ||||
| -rw-r--r-- | scripts/bower/README.md | 13 | ||||
| -rwxr-xr-x | scripts/bower/init.sh | 28 | ||||
| -rwxr-xr-x | scripts/bower/publish.sh | 45 | ||||
| -rw-r--r-- | scripts/code.angularjs.org/README.md | 19 | ||||
| -rwxr-xr-x | scripts/code.angularjs.org/publish.sh | 57 | ||||
| -rwxr-xr-x | scripts/jenkins/master.sh | 14 | ||||
| -rw-r--r-- | scripts/jenkins/release.sh | 29 |
11 files changed, 163 insertions, 62 deletions
diff --git a/Gruntfile.js b/Gruntfile.js index 43c3ef97..a3b4e97b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,6 +4,7 @@ var path = require('path'); module.exports = function(grunt) { //grunt plugins + grunt.loadNpmTasks('grunt-bump'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-connect'); @@ -268,6 +269,15 @@ module.exports = function(grunt) { write: { versionTXT: {file: 'build/version.txt', val: NG_VERSION.full}, versionJSON: {file: 'build/version.json', val: JSON.stringify(NG_VERSION)} + }, + + bump: { + options: { + files: ['package.json'], + commit: false, + createTag: false, + push: false + } } }); diff --git a/jenkins_build.sh b/jenkins_build.sh index fd0f424d..fd0f424d 100755..100644 --- a/jenkins_build.sh +++ b/jenkins_build.sh diff --git a/lib/grunt/utils.js b/lib/grunt/utils.js index 9e0aab99..51ebcc70 100644 --- a/lib/grunt/utils.js +++ b/lib/grunt/utils.js @@ -36,13 +36,12 @@ module.exports = { var package = JSON.parse(fs.readFileSync('package.json', 'UTF-8')); var match = package.version.match(/^([^\-]*)(?:\-(.+))?$/); var semver = match[1].split('.'); - var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', ''); var fullVersion = match[1]; if (match[2]) { fullVersion += '-'; - fullVersion += (match[2] == 'snapshot') ? hash : match[2]; + fullVersion += (match[2] == 'snapshot') ? getSnapshotSuffix() : match[2]; } version = { @@ -55,6 +54,12 @@ module.exports = { }; return version; + + function getSnapshotSuffix() { + var jenkinsBuild = process.env.BUILD_NUMBER || 'local'; + var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', ''); + return 'build.'+jenkinsBuild+'+sha.'+hash; + } }, diff --git a/package.json b/package.json index 2695aa0b..5eec1bf1 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "devDependencies": { "grunt": "~0.4.1", "bower": "~1.2.2", + "grunt-bump": "~0.0.13", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-compress": "~0.5.2", "grunt-contrib-connect": "~0.5.0", diff --git a/scripts/bower/README.md b/scripts/bower/README.md index 348d66ac..84da1baf 100644 --- a/scripts/bower/README.md +++ b/scripts/bower/README.md @@ -1,23 +1,18 @@ # Angular Bower Script -Script for updating the Angular bower repos from a code.angularjs.org package +Script for updating the Angular bower repos from current local build. -Requires `node` (for parsing `bower.json`) and `wget` (for fetching the `angular.zip` from `code.angularjs.org`) +Requires `node` (for parsing `bower.json`) ## Instructions -You need to run `./init.sh` the first time you use this script to clone all the repos. - -For subsequent updates: +`grunt package`: Build angular locally ```shell -./publish.sh NEW_VERSION +./publish.sh ``` -Where `NEW_VERSION` is a version number like `1.2.3`. - - ## License MIT diff --git a/scripts/bower/init.sh b/scripts/bower/init.sh deleted file mode 100755 index 74f310b0..00000000 --- a/scripts/bower/init.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# -# init all of the bower repos -# - -set -e # fail if any command fails - -REPOS=( - angular \ - angular-animate \ - angular-cookies \ - angular-i18n \ - angular-loader \ - angular-mocks \ - angular-route \ - angular-resource \ - angular-sanitize \ - angular-scenario \ - angular-touch \ -) - -cd `dirname $0` - -for repo in "${REPOS[@]}" -do - git clone git@github.com:angular/bower-$repo.git -done diff --git a/scripts/bower/publish.sh b/scripts/bower/publish.sh index 3575e8e8..fec1927d 100755 --- a/scripts/bower/publish.sh +++ b/scripts/bower/publish.sh @@ -7,12 +7,13 @@ set -e # fail if any command fails cd `dirname $0` +SCRIPT_DIR=`pwd` -NEW_VERSION=$1 +export TMP_DIR=../../tmp -ZIP_FILE=angular-$NEW_VERSION.zip -ZIP_FILE_URL=http://code.angularjs.org/$NEW_VERSION/angular-$NEW_VERSION.zip -ZIP_DIR=angular-$NEW_VERSION +export BUILD_DIR=../../build + +NEW_VERSION=$(node -e "console.log(require(process.env.BUILD_DIR+'/version.json').full)" | sed -e 's/\r//g') REPOS=( angular \ @@ -28,47 +29,45 @@ REPOS=( angular-touch \ ) - # -# download and unzip the file +# clone repos # - -if [ ! -f $ZIP_FILE ]; then - wget $ZIP_FILE_URL - unzip $ZIP_FILE -fi +for repo in "${REPOS[@]}" +do + git clone git@github.com:angular/bower-$repo.git $TMP_DIR/bower-$repo +done # -# move the files from the zip +# move the files from the build # for repo in "${REPOS[@]}" do - if [ -f $ZIP_DIR/$repo.js ] # ignore i18l + if [ -f $BUILD_DIR/$repo.js ] # ignore i18l then - cd bower-$repo + cd $TMP_DIR/bower-$repo git reset --hard HEAD git checkout master git fetch --all git reset --hard origin/master - cd .. - mv $ZIP_DIR/$repo.* bower-$repo/ + cd $SCRIPT_DIR + cp $BUILD_DIR/$repo.* $TMP_DIR/bower-$repo/ fi done # move i18n files -mv $ZIP_DIR/i18n/*.js bower-angular-i18n/ +cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/ # move csp.css -mv $ZIP_DIR/angular-csp.css bower-angular +cp $BUILD_DIR/angular-csp.css $TMP_DIR/bower-angular # # get the old version number # -OLD_VERSION=$(node -e "console.log(require('./bower-angular/bower').version)" | sed -e 's/\r//g') +OLD_VERSION=$(node -e "console.log(require(process.env.TMP_DIR+'/bower-angular/bower').version)" | sed -e 's/\r//g') echo $OLD_VERSION echo $NEW_VERSION @@ -79,12 +78,12 @@ echo $NEW_VERSION for repo in "${REPOS[@]}" do - cd bower-$repo + cd $TMP_DIR/bower-$repo sed -i '' -e "s/$OLD_VERSION/$NEW_VERSION/g" bower.json git add -A git commit -m "v$NEW_VERSION" git tag v$NEW_VERSION - git push origin master - git push origin v$NEW_VERSION - cd .. + # TODO git push origin master + # TODO git push origin v$NEW_VERSION + cd $SCRIPT_DIR done diff --git a/scripts/code.angularjs.org/README.md b/scripts/code.angularjs.org/README.md new file mode 100644 index 00000000..fd034102 --- /dev/null +++ b/scripts/code.angularjs.org/README.md @@ -0,0 +1,19 @@ +# code.angular.js.org Script + +Script for updating code.angularjs.org repo from current local build. + +Requires `node` (for parsing `bower.json`) + +Note: This should only be run for a release build, not a snapshot build! + +## Instructions + +`grunt package`: Build angular locally + +```shell +./publish.sh +``` + +## License +MIT + diff --git a/scripts/code.angularjs.org/publish.sh b/scripts/code.angularjs.org/publish.sh new file mode 100755 index 00000000..9eab269a --- /dev/null +++ b/scripts/code.angularjs.org/publish.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# +# update all the things +# + +set -e # fail if any command fails + +cd `dirname $0` +SCRIPT_DIR=`pwd` + +export TMP_DIR=../../tmp +export REPO_DIR=$TMP_DIR/code.angularjs.org + +export BUILD_DIR=../../build + +NEW_VERSION=$(node -e "console.log(require(process.env.BUILD_DIR+'/version.json').full)" | sed -e 's/\r//g') + +# +# Don't publish snapshot builds! +# +if [[ "$NEW_VERSION" =~ sha ]] ;then + echo "publish to code.angularjs.org is not allowed for snapshot builds" + exit 1; +fi + +exit 2 + +# +# clone +# + +git clone git@github.com:angular/code.angularjs.org.git $REPO_DIR + +# +# copy the files from the build +# + +mkdir $REPO_DIR/$NEW_VERSION + +cd $REPO_DIR +git reset --hard HEAD +git checkout master +git fetch --all +git reset --hard origin/master +cd $SCRIPT_DIR +cp -r $BUILD_DIR/* $REPO_DIR/$NEW_VERSION/ + +# +# commit and push +# + +cd $REPO_DIR +git add -A +git commit -m "v$NEW_VERSION" +# TODO git push origin master +cd $SCRIPT_DIR diff --git a/scripts/jenkins/master.sh b/scripts/jenkins/master.sh new file mode 100755 index 00000000..1e32ead2 --- /dev/null +++ b/scripts/jenkins/master.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e # fail if any command fails +cd `dirname $0`/../.. + +# Build +./jenkins_build.sh + +# Update code.angularjs.org +VERSION=`cat build/version.txt` +curl http://code.angularjs.org/fetchLatestSnapshot.php?ver=$VERSION + +# Push to bower +./scripts/bower/publish.sh
\ No newline at end of file diff --git a/scripts/jenkins/release.sh b/scripts/jenkins/release.sh new file mode 100644 index 00000000..88198d81 --- /dev/null +++ b/scripts/jenkins/release.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e # fail if any command fails +cd `dirname $0`/../.. + +# bump versions: remove "-snapshot" suffix +sed -i -e 's/"version": "\(.*\)-snapshot"/"version": "\1"/' package.json + +# Build +./jenkins_build.sh + +VERSION=`cat build/version.txt` + +# bump versions: increment version number and add "-snapshot" again +grunt bump:$BUMP_TYPE +sed -i -e 's/"version": "\(.*\)"/"version": "\1-snapshot"/' package.json + +# commit, tag and push +git commit -m "chore(release): v%VERSION%" +git tag -m "v%VERSION%" v%VERSION% +# TODO git push + +# Update code.angularjs.org +./scripts/code.angularjs.org/publish.sh + +# Push to bower +./scripts/bower/publish.sh + + |
