Skip to content

Commit 7efebc1

Browse files
committed
Run "sh release.sh -h" for a list of options.
1 parent 33758d5 commit 7efebc1

File tree

3 files changed

+195
-1
lines changed

3 files changed

+195
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ script:
1313
- 'grunt ngdocs:publish'
1414

1515
after_success:
16-
- sh -x ./publish.sh
16+
- sh -x ./scripts/publish.sh
1717

1818
deploy:
1919
provider: openshift
File renamed without changes.

scripts/release.sh

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
#!/bin/sh
2+
3+
default()
4+
{
5+
PATH=/bin:/usr/bin:/usr/local/bin:${PATH}
6+
export PATH
7+
8+
SCRIPT=`basename $0`
9+
SCRIPT_DIR=`dirname $0`
10+
SCRIPT_DIR=`cd $SCRIPT_DIR; pwd`
11+
TMP_DIR="/tmp/$SCRIPT.$$"
12+
13+
BOWER_JSON=bower.json
14+
PACKAGE_JSON=package.json
15+
16+
PTNFLY_REPO=https://github.com/patternfly/angular-patternfly.git
17+
PTNFLY_DIR="$TMP_DIR/angular-patternfly"
18+
VERIFY_DIR="$TMP_DIR/verify"
19+
}
20+
21+
build()
22+
{
23+
cd $PTNFLY_DIR
24+
25+
echo "*** Building `pwd`"
26+
grunt build
27+
check $? "Build failure"
28+
29+
echo "Building ngDocs: "`pwd`
30+
grunt ngdocs:publish
31+
check $? "ngDocs build failure"
32+
}
33+
34+
# Bump version in bower.json
35+
bump_bower()
36+
{
37+
echo "*** Bumping version in $BOWER_JSON to $VERSION"
38+
cd $PTNFLY_DIR
39+
40+
sed "s|\"version\":.*|\"version\": \"$VERSION\",|" $BOWER_JSON | \
41+
sed "s|\"patternfly\":.*|\"patternfly\": \"~$VERSION\"|" > $BOWER_JSON.tmp
42+
mv $BOWER_JSON.tmp $BOWER_JSON
43+
}
44+
45+
# Bump version in package.json
46+
bump_package()
47+
{
48+
echo "*** Bumping version in $PACKAGE_JSON to $VERSION"
49+
cd $PTNFLY_DIR
50+
51+
sed "s|\"version\":.*|\"version\": \"$VERSION\",|" $PACKAGE_JSON > $PACKAGE_JSON.tmp
52+
mv $PACKAGE_JSON.tmp $PACKAGE_JSON
53+
}
54+
55+
# Check errors
56+
#
57+
# $1: Exit status
58+
# $2: Error message
59+
check()
60+
{
61+
if [ "$1" != 0 ]; then
62+
echo "*** Error: $2"
63+
exit 1
64+
fi
65+
}
66+
67+
# Clean dependencies
68+
clean()
69+
{
70+
echo "*** Cleaning dependencies"
71+
cd $PTNFLY_DIR
72+
73+
npm cache clean
74+
bower cache clean
75+
}
76+
77+
# Install dependencies
78+
install()
79+
{
80+
echo "*** Intsalling dependencies"
81+
npm install
82+
bower install
83+
}
84+
85+
# Test prerequisites
86+
prereqs()
87+
{
88+
JUNK=`which npm`
89+
check $? "Cannot find npm in path"
90+
91+
JUNK=`which bower`
92+
check $? "Cannot find bower in path"
93+
94+
JUNK=`which grunt`
95+
check $? "Cannot find grunt in path"
96+
}
97+
98+
# Push changes to remote repo
99+
push()
100+
{
101+
echo "*** Pushing changes to $PTNFLY_REPO"
102+
cd $PTNFLY_DIR
103+
104+
git add --all
105+
git commit -m "Bumped version number to $VERSION"
106+
107+
git push --set-upstream origin $BRANCH --force
108+
check $? "Push failure"
109+
}
110+
111+
# Setup local repo
112+
setup_repo() {
113+
echo "*** Setting up local repo $PTNFLY_DIR"
114+
mkdir -p $TMP_DIR
115+
cd $TMP_DIR
116+
117+
git clone $PTNFLY_REPO
118+
cd $PTNFLY_DIR
119+
120+
git checkout -B $BRANCH
121+
check $? "Local repo setup failure"
122+
}
123+
124+
usage()
125+
{
126+
cat <<- EEOOFF
127+
128+
This script will bump the version number for the Angular PatternFly repo.
129+
130+
Note: After changes are pushed, a PR will need to be created via GitHub.
131+
132+
sh [-x] $SCRIPT [-h|f] -v <version>
133+
134+
Example: sh $SCRIPT -v 3.7.0 -f
135+
136+
OPTIONS:
137+
h Display this message (default)
138+
f Force push to new repo branch (e.g., bump-v3.7.0)
139+
v The version number (e.g., 3.7.0)
140+
141+
EEOOFF
142+
}
143+
144+
verify()
145+
{
146+
mkdir -p $VERIFY_DIR
147+
cd $VERIFY_DIR
148+
149+
echo "*** Verifying bower install"
150+
bower install $PTNFLY_DIR
151+
check $? "bower install failure"
152+
}
153+
154+
# main()
155+
{
156+
default
157+
158+
if [ "$#" -eq 0 ]; then
159+
usage
160+
exit 1
161+
fi
162+
163+
while getopts hfv c; do
164+
case $c in
165+
h) usage; exit 0;;
166+
f) PUSH=1;;
167+
v) VERSION=$2; shift
168+
BRANCH=bump-v$VERSION;;
169+
\?) usage; exit 1;;
170+
esac
171+
done
172+
173+
if [ -z "$VERSION" ]; then
174+
usage
175+
exit 1
176+
fi
177+
178+
prereqs
179+
setup_repo
180+
bump_bower
181+
bump_package
182+
clean
183+
install
184+
build
185+
verify
186+
187+
if [ -n "$PUSH" ]; then
188+
push
189+
echo "*** Changes pushed to the $BRANCH branch of $PTNFLY_REPO"
190+
echo "*** Review changes and create a PR via GitHub"
191+
fi
192+
193+
echo "*** Remove $TMP_DIR directory manually after testing"
194+
}

0 commit comments

Comments
 (0)