Skip to content

Commit 8c10db3

Browse files
committed
chore(build): automate cutting a release, publishing to bower and to code.angular.js
1 parent 03088d6 commit 8c10db3

11 files changed

Lines changed: 163 additions & 62 deletions

File tree

Gruntfile.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var path = require('path');
44

55
module.exports = function(grunt) {
66
//grunt plugins
7+
grunt.loadNpmTasks('grunt-bump');
78
grunt.loadNpmTasks('grunt-contrib-clean');
89
grunt.loadNpmTasks('grunt-contrib-copy');
910
grunt.loadNpmTasks('grunt-contrib-connect');
@@ -268,6 +269,15 @@ module.exports = function(grunt) {
268269
write: {
269270
versionTXT: {file: 'build/version.txt', val: NG_VERSION.full},
270271
versionJSON: {file: 'build/version.json', val: JSON.stringify(NG_VERSION)}
272+
},
273+
274+
bump: {
275+
options: {
276+
files: ['package.json'],
277+
commit: false,
278+
createTag: false,
279+
push: false
280+
}
271281
}
272282
});
273283

jenkins_build.sh

100755100644
File mode changed.

lib/grunt/utils.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ module.exports = {
3636
var package = JSON.parse(fs.readFileSync('package.json', 'UTF-8'));
3737
var match = package.version.match(/^([^\-]*)(?:\-(.+))?$/);
3838
var semver = match[1].split('.');
39-
var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', '');
4039

4140
var fullVersion = match[1];
4241

4342
if (match[2]) {
4443
fullVersion += '-';
45-
fullVersion += (match[2] == 'snapshot') ? hash : match[2];
44+
fullVersion += (match[2] == 'snapshot') ? getSnapshotSuffix() : match[2];
4645
}
4746

4847
version = {
@@ -55,6 +54,12 @@ module.exports = {
5554
};
5655

5756
return version;
57+
58+
function getSnapshotSuffix() {
59+
var jenkinsBuild = process.env.BUILD_NUMBER || 'local';
60+
var hash = shell.exec('git rev-parse --short HEAD', {silent: true}).output.replace('\n', '');
61+
return 'build.'+jenkinsBuild+'+sha.'+hash;
62+
}
5863
},
5964

6065

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"devDependencies": {
1111
"grunt": "~0.4.1",
1212
"bower": "~1.2.2",
13+
"grunt-bump": "~0.0.13",
1314
"grunt-contrib-clean": "~0.5.0",
1415
"grunt-contrib-compress": "~0.5.2",
1516
"grunt-contrib-connect": "~0.5.0",

scripts/bower/README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
# Angular Bower Script
22

3-
Script for updating the Angular bower repos from a code.angularjs.org package
3+
Script for updating the Angular bower repos from current local build.
44

5-
Requires `node` (for parsing `bower.json`) and `wget` (for fetching the `angular.zip` from `code.angularjs.org`)
5+
Requires `node` (for parsing `bower.json`)
66

77

88
## Instructions
99

10-
You need to run `./init.sh` the first time you use this script to clone all the repos.
11-
12-
For subsequent updates:
10+
`grunt package`: Build angular locally
1311

1412
```shell
15-
./publish.sh NEW_VERSION
13+
./publish.sh
1614
```
1715

18-
Where `NEW_VERSION` is a version number like `1.2.3`.
19-
20-
2116
## License
2217
MIT
2318

scripts/bower/init.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/bower/publish.sh

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
set -e # fail if any command fails
88

99
cd `dirname $0`
10+
SCRIPT_DIR=`pwd`
1011

11-
NEW_VERSION=$1
12+
export TMP_DIR=../../tmp
1213

13-
ZIP_FILE=angular-$NEW_VERSION.zip
14-
ZIP_FILE_URL=http://code.angularjs.org/$NEW_VERSION/angular-$NEW_VERSION.zip
15-
ZIP_DIR=angular-$NEW_VERSION
14+
export BUILD_DIR=../../build
15+
16+
NEW_VERSION=$(node -e "console.log(require(process.env.BUILD_DIR+'/version.json').full)" | sed -e 's/\r//g')
1617

1718
REPOS=(
1819
angular \
@@ -28,47 +29,45 @@ REPOS=(
2829
angular-touch \
2930
)
3031

31-
3232
#
33-
# download and unzip the file
33+
# clone repos
3434
#
35-
36-
if [ ! -f $ZIP_FILE ]; then
37-
wget $ZIP_FILE_URL
38-
unzip $ZIP_FILE
39-
fi
35+
for repo in "${REPOS[@]}"
36+
do
37+
git clone [email protected]:angular/bower-$repo.git $TMP_DIR/bower-$repo
38+
done
4039

4140

4241
#
43-
# move the files from the zip
42+
# move the files from the build
4443
#
4544

4645
for repo in "${REPOS[@]}"
4746
do
48-
if [ -f $ZIP_DIR/$repo.js ] # ignore i18l
47+
if [ -f $BUILD_DIR/$repo.js ] # ignore i18l
4948
then
50-
cd bower-$repo
49+
cd $TMP_DIR/bower-$repo
5150
git reset --hard HEAD
5251
git checkout master
5352
git fetch --all
5453
git reset --hard origin/master
55-
cd ..
56-
mv $ZIP_DIR/$repo.* bower-$repo/
54+
cd $SCRIPT_DIR
55+
cp $BUILD_DIR/$repo.* $TMP_DIR/bower-$repo/
5756
fi
5857
done
5958

6059
# move i18n files
61-
mv $ZIP_DIR/i18n/*.js bower-angular-i18n/
60+
cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/
6261

6362
# move csp.css
64-
mv $ZIP_DIR/angular-csp.css bower-angular
63+
cp $BUILD_DIR/angular-csp.css $TMP_DIR/bower-angular
6564

6665

6766
#
6867
# get the old version number
6968
#
7069

71-
OLD_VERSION=$(node -e "console.log(require('./bower-angular/bower').version)" | sed -e 's/\r//g')
70+
OLD_VERSION=$(node -e "console.log(require(process.env.TMP_DIR+'/bower-angular/bower').version)" | sed -e 's/\r//g')
7271
echo $OLD_VERSION
7372
echo $NEW_VERSION
7473

@@ -79,12 +78,12 @@ echo $NEW_VERSION
7978

8079
for repo in "${REPOS[@]}"
8180
do
82-
cd bower-$repo
81+
cd $TMP_DIR/bower-$repo
8382
sed -i '' -e "s/$OLD_VERSION/$NEW_VERSION/g" bower.json
8483
git add -A
8584
git commit -m "v$NEW_VERSION"
8685
git tag v$NEW_VERSION
87-
git push origin master
88-
git push origin v$NEW_VERSION
89-
cd ..
86+
# TODO git push origin master
87+
# TODO git push origin v$NEW_VERSION
88+
cd $SCRIPT_DIR
9089
done
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# code.angular.js.org Script
2+
3+
Script for updating code.angularjs.org repo from current local build.
4+
5+
Requires `node` (for parsing `bower.json`)
6+
7+
Note: This should only be run for a release build, not a snapshot build!
8+
9+
## Instructions
10+
11+
`grunt package`: Build angular locally
12+
13+
```shell
14+
./publish.sh
15+
```
16+
17+
## License
18+
MIT
19+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
#
4+
# update all the things
5+
#
6+
7+
set -e # fail if any command fails
8+
9+
cd `dirname $0`
10+
SCRIPT_DIR=`pwd`
11+
12+
export TMP_DIR=../../tmp
13+
export REPO_DIR=$TMP_DIR/code.angularjs.org
14+
15+
export BUILD_DIR=../../build
16+
17+
NEW_VERSION=$(node -e "console.log(require(process.env.BUILD_DIR+'/version.json').full)" | sed -e 's/\r//g')
18+
19+
#
20+
# Don't publish snapshot builds!
21+
#
22+
if [[ "$NEW_VERSION" =~ sha ]] ;then
23+
echo "publish to code.angularjs.org is not allowed for snapshot builds"
24+
exit 1;
25+
fi
26+
27+
exit 2
28+
29+
#
30+
# clone
31+
#
32+
33+
git clone [email protected]:angular/code.angularjs.org.git $REPO_DIR
34+
35+
#
36+
# copy the files from the build
37+
#
38+
39+
mkdir $REPO_DIR/$NEW_VERSION
40+
41+
cd $REPO_DIR
42+
git reset --hard HEAD
43+
git checkout master
44+
git fetch --all
45+
git reset --hard origin/master
46+
cd $SCRIPT_DIR
47+
cp -r $BUILD_DIR/* $REPO_DIR/$NEW_VERSION/
48+
49+
#
50+
# commit and push
51+
#
52+
53+
cd $REPO_DIR
54+
git add -A
55+
git commit -m "v$NEW_VERSION"
56+
# TODO git push origin master
57+
cd $SCRIPT_DIR

scripts/jenkins/master.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e # fail if any command fails
4+
cd `dirname $0`/../..
5+
6+
# Build
7+
./jenkins_build.sh
8+
9+
# Update code.angularjs.org
10+
VERSION=`cat build/version.txt`
11+
curl http://code.angularjs.org/fetchLatestSnapshot.php?ver=$VERSION
12+
13+
# Push to bower
14+
./scripts/bower/publish.sh

0 commit comments

Comments
 (0)