Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5dc2795

Browse files
committed
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
1 parent 4c21355 commit 5dc2795

File tree

12 files changed

+582
-267
lines changed

12 files changed

+582
-267
lines changed
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+
ARG_DEFS=()
8+
9+
function run {
10+
cd ../..
11+
12+
replaceJsonProp "package.json" "version" "(.*)-snapshot" "\2"
13+
VERSION=$(readJsonProp "package.json" "version")
14+
15+
git add package.json
16+
git commit -m "chore(release): cut v$VERSION release"
17+
git tag -m "v$VERSION" v$VERSION
18+
}
19+
20+
source $(dirname $0)/../utils.inc
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
echo "############################################"
4+
echo "## Increment version, add "-snapshot" and set version name ##"
5+
echo "############################################"
6+
7+
ARG_DEFS=(
8+
"--next-version-type=(patch|minor|major)"
9+
"--next-version-name=(.+)"
10+
)
11+
12+
function run {
13+
cd ../..
14+
15+
grunt bump:$NEXT_VERSION_TYPE
16+
NEXT_VERSION=$(readJsonProp "package.json" "version")
17+
replaceJsonProp "package.json" "version" "(.*)" "\2-snapshot"
18+
replaceJsonProp "package.json" "codename" ".*" "$NEXT_VERSION_NAME"
19+
20+
git add package.json
21+
git commit -m "chore(release): start v$NEXT_VERSION ($NEXT_VERSION)"
22+
}
23+
24+
source $(dirname $0)/../utils.inc

scripts/angular.js/publish.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# Script for updating angular.js repo from current local build.
4+
5+
echo "#################################"
6+
echo "## Update angular.js ###"
7+
echo "#################################"
8+
9+
ARG_DEFS=(
10+
"--action=(prepare|publish)"
11+
"--next-version-type=(patch|minor|major)"
12+
"--next-version-name=(.+)"
13+
"[--no_test=true]"
14+
)
15+
16+
function init {
17+
cd ../..
18+
}
19+
20+
function prepare() {
21+
22+
if ! git symbolic-ref --short HEAD; then
23+
# We are on a detached branch, e.g. jenkins checks out shas instead of branches
24+
# Jump onto the master branch and make sure we are using the latest
25+
git checkout -f master
26+
git merge --ff-only origin/master
27+
fi
28+
29+
./scripts/angular.js/finalize-version.sh
30+
31+
# Build
32+
if [[ $NO_TEST ]]; then
33+
grunt package
34+
else
35+
./jenkins_build.sh
36+
fi
37+
38+
./scripts/angular.js/initialize-new-version.sh --next-version-type=$NEXT_VERSION_TYPE --next-version-name=$NEXT_VERSION_NAME
39+
}
40+
41+
function publish() {
42+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
43+
# push the commits to github
44+
git push origin $BRANCH
45+
# push the release tag
46+
git push origin v`cat build/version.txt`
47+
}
48+
49+
source $(dirname $0)/../utils.inc

scripts/bower/README.md

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

scripts/bower/publish.sh

Lines changed: 93 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,101 @@
11
#!/bin/bash
22

3+
# Script for updating the Angular bower repos from current local build.
4+
35
echo "#################################"
46
echo "#### Update bower ###############"
57
echo "#################################"
68

7-
# Enable tracing and exit on first failure
8-
set -xe
9-
# Normalize working dir to script dir
10-
cd `dirname $0`
11-
12-
SCRIPT_DIR=`pwd`
13-
TMP_DIR=../../tmp
14-
BUILD_DIR=../../build
15-
NEW_VERSION=`cat $BUILD_DIR/version.txt`
16-
17-
REPOS=(
18-
angular \
19-
angular-animate \
20-
angular-cookies \
21-
angular-i18n \
22-
angular-loader \
23-
angular-mocks \
24-
angular-route \
25-
angular-resource \
26-
angular-sanitize \
27-
angular-scenario \
28-
angular-touch \
9+
ARG_DEFS=(
10+
"--action=(prepare|publish)"
2911
)
3012

31-
#
32-
# clone repos
33-
#
34-
for repo in "${REPOS[@]}"
35-
do
36-
echo "-- Cloning bower-$repo"
37-
git clone git@github.com:angular/bower-$repo.git $TMP_DIR/bower-$repo
38-
done
39-
40-
41-
#
42-
# move the files from the build
43-
#
44-
45-
for repo in "${REPOS[@]}"
46-
do
47-
if [ -f $BUILD_DIR/$repo.js ] # ignore i18l
48-
then
49-
echo "-- Updating files in bower-$repo"
50-
cd $TMP_DIR/bower-$repo
51-
git reset --hard HEAD
52-
git checkout master
53-
git fetch --all
54-
git reset --hard origin/master
55-
cd $SCRIPT_DIR
56-
cp $BUILD_DIR/$repo.* $TMP_DIR/bower-$repo/
57-
fi
58-
done
59-
60-
# move i18n files
61-
cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/
62-
63-
# move csp.css
64-
cp $BUILD_DIR/angular-csp.css $TMP_DIR/bower-angular
65-
66-
67-
#
68-
# update bower.json
69-
# tag each repo
70-
#
71-
72-
for repo in "${REPOS[@]}"
73-
do
74-
echo "-- Updating version in bower-$repo to $NEW_VERSION"
75-
cd $TMP_DIR/bower-$repo
76-
sed -i .tmp -E 's/"(version)":[ ]*".*"/"\1": "'$NEW_VERSION'"/g' bower.json
77-
sed -i .tmp -E 's/"(angular.*)":[ ]*".*"/"\1": "'$NEW_VERSION'"/g' bower.json
78-
# delete tmp files
79-
rm *.tmp
80-
git add -A
81-
82-
echo "-- Committing, tagging and pushing bower-$repo"
83-
git commit -m "v$NEW_VERSION"
84-
git tag v$NEW_VERSION
85-
git push origin master
86-
git push origin v$NEW_VERSION
87-
cd $SCRIPT_DIR
88-
done
13+
function init {
14+
TMP_DIR=$(resolveDir ../../tmp)
15+
BUILD_DIR=$(resolveDir ../../build)
16+
NEW_VERSION=$(cat $BUILD_DIR/version.txt)
17+
REPOS=(
18+
angular
19+
angular-animate
20+
angular-cookies
21+
angular-i18n
22+
angular-loader
23+
angular-mocks
24+
angular-route
25+
angular-resource
26+
angular-sanitize
27+
angular-scenario
28+
angular-touch
29+
)
30+
}
31+
32+
33+
function prepare {
34+
#
35+
# clone repos
36+
#
37+
for repo in "${REPOS[@]}"
38+
do
39+
echo "-- Cloning bower-$repo"
40+
git clone git@github.com:angular/bower-$repo.git $TMP_DIR/bower-$repo
41+
done
42+
43+
44+
#
45+
# move the files from the build
46+
#
47+
48+
for repo in "${REPOS[@]}"
49+
do
50+
if [ -f $BUILD_DIR/$repo.js ] # ignore i18l
51+
then
52+
echo "-- Updating files in bower-$repo"
53+
cd $TMP_DIR/bower-$repo
54+
git reset --hard HEAD
55+
git checkout master
56+
git fetch --all
57+
git reset --hard origin/master
58+
cd $SCRIPT_DIR
59+
cp $BUILD_DIR/$repo.* $TMP_DIR/bower-$repo/
60+
fi
61+
done
62+
63+
# move i18n files
64+
cp $BUILD_DIR/i18n/*.js $TMP_DIR/bower-angular-i18n/
65+
66+
# move csp.css
67+
cp $BUILD_DIR/angular-csp.css $TMP_DIR/bower-angular
68+
69+
70+
#
71+
# update bower.json
72+
# tag each repo
73+
#
74+
for repo in "${REPOS[@]}"
75+
do
76+
echo "-- Updating version in bower-$repo to $NEW_VERSION"
77+
cd $TMP_DIR/bower-$repo
78+
replaceJsonProp "bower.json" "version" ".*" "$NEW_VERSION"
79+
replaceJsonProp "bower.json" "angular.*" ".*" "$NEW_VERSION"
80+
81+
git add -A
82+
83+
echo "-- Committing and tagging bower-$repo"
84+
git commit -m "v$NEW_VERSION"
85+
git tag v$NEW_VERSION
86+
cd $SCRIPT_DIR
87+
done
88+
}
89+
90+
function publish {
91+
for repo in "${REPOS[@]}"
92+
do
93+
echo "-- Pushing bower-$repo"
94+
cd $TMP_DIR/bower-$repo
95+
git push origin master
96+
git push origin v$NEW_VERSION
97+
cd $SCRIPT_DIR
98+
done
99+
}
100+
101+
source $(dirname $0)/../utils.inc

scripts/code.angularjs.org/README.md

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

0 commit comments

Comments
 (0)