Skip to content

Commit 9a4c9e6

Browse files
committed
chore(build): correct and refactor release script
1 parent 11fff8f commit 9a4c9e6

7 files changed

Lines changed: 125 additions & 53 deletions

File tree

jenkins_build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/bash
22

3+
echo "#################################"
4+
echo "#### Jenkins Build ############"
5+
echo "#################################"
6+
37
# Enable tracing and exit on first failure
48
set -xe
59

6-
710
# Define reasonable set of browsers in case we are running manually from commandline
811
if [[ -z "$BROWSERS" ]]
912
then

scripts/bower/publish.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
#!/bin/bash
22

3-
#
4-
# update all the things
5-
#
6-
7-
set -e # fail if any command fails
3+
echo "#################################"
4+
echo "#### Update bower ###############"
5+
echo "#################################"
86

7+
# Enable tracing and exit on first failure
8+
set -xe
9+
# Normalize working dir to script dir
910
cd `dirname $0`
11+
1012
SCRIPT_DIR=`pwd`
1113

14+
# export so that node.js can read those env settings
1215
export TMP_DIR=../../tmp
13-
1416
export BUILD_DIR=../../build
1517

16-
NEW_VERSION=$(node -e "console.log(require(process.env.BUILD_DIR+'/version.json').full)" | sed -e 's/\r//g')
18+
NEW_VERSION=`cat $BUILD_DIR/version.txt`
1719

1820
REPOS=(
1921
angular \
@@ -34,6 +36,7 @@ REPOS=(
3436
#
3537
for repo in "${REPOS[@]}"
3638
do
39+
echo "-- Cloning bower-$repo"
3740
git clone git@github.com:angular/bower-$repo.git $TMP_DIR/bower-$repo
3841
done
3942

@@ -46,6 +49,7 @@ for repo in "${REPOS[@]}"
4649
do
4750
if [ -f $BUILD_DIR/$repo.js ] # ignore i18l
4851
then
52+
echo "-- Updating files in bower-$repo"
4953
cd $TMP_DIR/bower-$repo
5054
git reset --hard HEAD
5155
git checkout master
@@ -78,12 +82,15 @@ echo $NEW_VERSION
7882

7983
for repo in "${REPOS[@]}"
8084
do
85+
echo "-- Updating version in bower-$repo from $OLD_VERSION to $NEW_VERSION"
8186
cd $TMP_DIR/bower-$repo
8287
sed -i '' -e "s/$OLD_VERSION/$NEW_VERSION/g" bower.json
8388
git add -A
89+
90+
echo "-- Committing, tagging and pushing bower-$repo"
8491
git commit -m "v$NEW_VERSION"
8592
git tag v$NEW_VERSION
86-
# TODO git push origin master
87-
# TODO git push origin v$NEW_VERSION
93+
git push origin master
94+
git push origin v$NEW_VERSION
8895
cd $SCRIPT_DIR
8996
done
Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
11
#!/bin/bash
22

3-
#
4-
# update all the things
5-
#
6-
7-
set -e # fail if any command fails
3+
echo "#################################"
4+
echo "## Update code.angular.js.org ###"
5+
echo "#################################"
86

7+
# Enable tracing and exit on first failure
8+
set -xe
9+
# Normalize working dir to script dir
910
cd `dirname $0`
10-
SCRIPT_DIR=`pwd`
1111

12+
13+
# export so that node.js can read those env settings
1214
export TMP_DIR=../../tmp
1315
export REPO_DIR=$TMP_DIR/code.angularjs.org
14-
1516
export BUILD_DIR=../../build
1617

17-
NEW_VERSION=$(node -e "console.log(require(process.env.BUILD_DIR+'/version.json').full)" | sed -e 's/\r//g')
18+
SCRIPT_DIR=`pwd`
19+
NEW_VERSION=`cat $BUILD_DIR/version.txt`
1820

1921
#
20-
# Don't publish snapshot builds!
22+
# Snapshot builds are kept in a temp directory in code.angularjs.org
23+
# that is filled by calling a php script there.
2124
#
2225
if [[ "$NEW_VERSION" =~ sha ]] ;then
23-
echo "publish to code.angularjs.org is not allowed for snapshot builds"
24-
exit 1;
26+
echo "-- updating snapshot version"
27+
curl -G --data-urlencode "ver=$NEW_VERSION" http://code.angularjs.org/fetchLatestSnapshot.php
28+
exit 0;
2529
fi
2630

27-
exit 2
28-
2931
#
3032
# clone
3133
#
3234

35+
echo "-- Cloning code.angularjs.org"
3336
git clone git@github.com:angular/code.angularjs.org.git $REPO_DIR
3437

3538
#
3639
# copy the files from the build
3740
#
3841

42+
echo "-- Updating code.angularjs.org"
3943
mkdir $REPO_DIR/$NEW_VERSION
40-
4144
cd $REPO_DIR
4245
git reset --hard HEAD
4346
git checkout master
@@ -49,9 +52,14 @@ cp -r $BUILD_DIR/* $REPO_DIR/$NEW_VERSION/
4952
#
5053
# commit and push
5154
#
52-
55+
echo "-- Committing and pushing code.angularjs.org"
5356
cd $REPO_DIR
5457
git add -A
5558
git commit -m "v$NEW_VERSION"
56-
# TODO git push origin master
59+
git push origin master
5760
cd $SCRIPT_DIR
61+
62+
#
63+
# refresh code.angularjs.org from github
64+
#
65+
curl http://code.angularjs.org/gitFetchSite.php

scripts/jenkins/bump-increment.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
echo "############################################"
4+
echo "## Increment version and add "-snapshot" ##"
5+
echo "############################################"
6+
7+
if [ "$1" != "patch" -a "$1" != "minor" -a "$1" != "major" ]; then
8+
echo "Please specify the next version type: patch|minor|major"
9+
exit 1
10+
fi
11+
BUMP_TYPE=$1
12+
13+
# Enable tracing and exit on first failure
14+
set -xe
15+
# Normalize working dir to script dir
16+
cd `dirname $0`/../..
17+
18+
echo "-- increment version "
19+
grunt bump:$BUMP_TYPE
20+
NEXT_VERSION=$(node -e "console.log(require('./package.json').version)" | sed -e 's/\r//g')
21+
sed -i .tmp -e 's/"version": "\(.*\)"/"version": "\1-snapshot"/' package.json
22+
echo "-- new version: `grep '"version"' package.json`"
23+
echo "-- commit"
24+
git add package.json
25+
git commit -m "chore(release): start v$NEXT_VERSION"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
echo "############################################"
4+
echo "## Remove "-snapshot" from version ########"
5+
echo "############################################"
6+
7+
# Enable tracing and exit on first failure
8+
set -xe
9+
# Normalize working dir to script dir
10+
cd `dirname $0`/../..
11+
12+
echo "-- old version: `grep '"version"' package.json`"
13+
sed -i .tmp -e 's/"version": "\(.*\)-snapshot"/"version": "\1"/' package.json
14+
VERSION=$(node -e "console.log(require('./package.json').version)" | sed -e 's/\r//g')
15+
echo "-- local version: $VERSION"
16+
17+
echo "-- commit and tag with v$VERSION"
18+
git add package.json
19+
git commit -m "chore(release): v$VERSION"
20+
git tag -m "v$VERSION" v$VERSION

scripts/jenkins/master.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
#!/bin/bash
22

3-
set -e # fail if any command fails
3+
echo "#################################"
4+
echo "#### Update master ##############"
5+
echo "#################################"
6+
7+
# Enable tracing and exit on first failure
8+
set -xe
9+
410
cd `dirname $0`/../..
511

6-
# Build
12+
echo "#################################"
13+
echo "#### Jenkins Build ############"
14+
echo "#################################"
715
./jenkins_build.sh
816

9-
# Update code.angularjs.org
10-
VERSION=`cat build/version.txt`
11-
curl -G --data-urlencode 'ver=$VERSION' http://code.angularjs.org/fetchLatestSnapshot.php
17+
echo "#################################"
18+
echo "## Update code.angular.js.org ###"
19+
echo "#################################"
20+
./scripts/code.angularjs.org/publish.sh
1221

13-
# Push to bower
22+
echo "#################################"
23+
echo "#### Update bower ###############"
24+
echo "#################################"
1425
./scripts/bower/publish.sh

scripts/jenkins/release.sh

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
11
#!/bin/bash
22

3-
if [ -z "$1" ]; then
4-
echo "Please specify the version bump type: patch|minor|major"
5-
exit 1
3+
echo "#################################"
4+
echo "#### Cut release ################"
5+
echo "#################################"
6+
7+
if [ "$1" != "patch" -a "$1" != "minor" -a "$1" != "major" ]; then
8+
echo "Please specify the next version type: patch|minor|major"
9+
exit 1
610
fi
11+
BUMP_TYPE=$1
712

8-
set -e # fail if any command fails
13+
# Enable tracing and exit on first failure
14+
set -xe
15+
# Normalize working dir to script dir
916
cd `dirname $0`/../..
10-
BUMP_TYPE=$1
1117

12-
# bump versions: remove "-snapshot" suffix
13-
sed -i .tmp -e 's/"version": "\(.*\)-snapshot"/"version": "\1"/' package.json
18+
19+
# Bump versions: remove "-snapshot" suffix
20+
./scripts/jenkins/bump-remove-snapshot.sh
1421

1522
# Build
1623
./jenkins_build.sh
17-
VERSION=`cat build/version.txt`
18-
19-
# Commit and tag
20-
git add package.json
21-
git commit -m "chore(release): v$VERSION"
22-
git tag -m "v$VERSION" v$VERSION
2324

24-
# bump versions: increment version number and add "-snapshot"
25-
grunt bump:$BUMP_TYPE
26-
NEXT_VERSION=$(node -e "console.log(require('./package.json').version)" | sed -e 's/\r//g')
27-
sed -i .tmp -e 's/"version": "\(.*\)"/"version": "\1-snapshot"/' package.json
28-
git add package.json
29-
git commit -m "chore(release): start v$NEXT_VERSION"
25+
# Bump versions: Increment version and add "-snapshot"
26+
./scripts/jenkins/bump-increment.sh $BUMP_TYPE
3027

28+
echo "-- push to Github"
3129
# push to github
32-
# TODO git push
30+
git push
3331

3432
# Update code.angularjs.org
3533
./scripts/code.angularjs.org/publish.sh
3634

37-
# Push to bower
35+
# Update bower
3836
./scripts/bower/publish.sh
3937

4038

0 commit comments

Comments
 (0)