Skip to content

Commit ae47374

Browse files
authored
Merge pull request #293 from dlabrecq/PTNFLY-release
Added functionality for shrink-wrap and npm publish
2 parents 1e03e6e + d86e4c1 commit ae47374

File tree

1 file changed

+51
-12
lines changed

1 file changed

+51
-12
lines changed

scripts/release.sh

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ prereqs()
103103
check $? "Cannot find grunt in path"
104104
}
105105

106+
# Publish to npm
107+
publish()
108+
{
109+
echo "*** Publishing npm"
110+
cd $PTNFLY_DIR
111+
112+
npm publish
113+
check $? "npm publish failure"
114+
}
115+
106116
# Push changes to remote repo
107117
push()
108118
{
@@ -131,6 +141,21 @@ setup_repo() {
131141
check $? "Local repo setup failure"
132142
}
133143

144+
# Shrink wrap npm
145+
shrinkwrap()
146+
{
147+
echo "*** Shrink wrapping $SHRINKWRAP_JSON"
148+
cd $PTNFLY_DIR
149+
150+
# shrinkwrap
151+
if [ -s $SHRINKWRAP_JSON ]; then
152+
rm -f $SHRINKWRAP_JSON
153+
fi
154+
155+
npm shrinkwrap
156+
check $? "npm shrinkwrap failure"
157+
}
158+
134159
usage()
135160
{
136161
cat <<- EEOOFF
@@ -139,13 +164,14 @@ cat <<- EEOOFF
139164
140165
Note: After changes are pushed, a PR will need to be created via GitHub.
141166
142-
sh [-x] $SCRIPT [-h|f|s] -v <version>
167+
sh [-x] $SCRIPT [-h|p|f|s] -v <version>
143168
144169
Example: sh $SCRIPT -v 3.7.0 -f
145170
146171
OPTIONS:
147-
h Display this message (default)
172+
h Display this message (default)
148173
f Force push to new repo branch (e.g., bump-v3.7.0)
174+
p Publish to npm from latest repo clone
149175
s Skip new clone, clean, and install to rebuild previously created repo
150176
v The version number (e.g., 3.7.0)
151177
@@ -160,6 +186,9 @@ verify()
160186
mkdir -p $VERIFY_DIR
161187
cd $VERIFY_DIR
162188

189+
npm install $PTNFLY_DIR
190+
check $? "npm install failure"
191+
163192
bower install $PTNFLY_DIR
164193
check $? "bower install failure"
165194
}
@@ -173,18 +202,20 @@ verify()
173202
exit 1
174203
fi
175204

176-
while getopts hfsv c; do
205+
while getopts hfpsv c; do
177206
case $c in
178207
h) usage; exit 0;;
179208
f) PUSH=1;;
209+
p) PUBLISH=1
210+
BRANCH=master-dist;;
180211
s) SETUP=1;;
181212
v) VERSION=$2; shift
182213
BRANCH=bump-v$VERSION;;
183214
\?) usage; exit 1;;
184215
esac
185216
done
186217

187-
if [ -z "$VERSION" ]; then
218+
if [ -z "$VERSION" -a -z "$PUBLISH" -o -n "$VERSION" -a -n "$PUBLISH" ]; then
188219
usage
189220
exit 1
190221
fi
@@ -195,16 +226,24 @@ verify()
195226
setup_repo
196227
fi
197228

198-
bump_bower
199-
bump_package
229+
if [ -z "$PUBLISH" ]; then
230+
bump_bower
231+
bump_package
200232

201-
if [ -z "$SETUP" ]; then
202-
clean
203-
install
204-
fi
233+
if [ -z "$SETUP" ]; then
234+
clean
235+
install
236+
fi
205237

206-
build
207-
verify
238+
build
239+
shrinkwrap
240+
verify
241+
else
242+
publish
243+
244+
# Skip remaining steps for npm publish
245+
exit 0
246+
fi
208247

209248
if [ -n "$PUSH" ]; then
210249
push

0 commit comments

Comments
 (0)