|
|
@@ -28,38 +28,51 @@ then
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
-# ensures stray files stay out of the release
|
|
|
-gulp clean
|
|
|
+success=0
|
|
|
+if ! {
|
|
|
+ # make sure deps are as new as possible for bundle
|
|
|
+ npm install && \
|
|
|
|
|
|
-# make sure deps are as new as possible for bundle
|
|
|
-npm install
|
|
|
+ # ensures stray files stay out of the release
|
|
|
+ gulp clean && \
|
|
|
|
|
|
-# update package manager json files with version number and release date
|
|
|
-gulp bump --version=$version
|
|
|
+ # update package manager json files with version number and release date
|
|
|
+ gulp bump --version=$version && \
|
|
|
|
|
|
-# build all dist files and run tests
|
|
|
-gulp release
|
|
|
-
|
|
|
-# save reference to current branch
|
|
|
-orig_ref=$(git symbolic-ref --quiet HEAD)
|
|
|
+ # build all dist files, lint, and run tests
|
|
|
+ gulp release
|
|
|
+}
|
|
|
+then
|
|
|
+ # failure. discard changes from version bump
|
|
|
+ git checkout -- *.json
|
|
|
+else
|
|
|
+ # save reference to current branch
|
|
|
+ orig_ref=$(git symbolic-ref --quiet HEAD)
|
|
|
|
|
|
-# make a tagged detached commit of the dist files.
|
|
|
-# no-verify avoids commit hooks.
|
|
|
-# make this a boolean expression that doesn't exit upon error.
|
|
|
-git checkout --detach --quiet && \
|
|
|
-git add *.json && \
|
|
|
-git add -f dist/*.js dist/*.css dist/locale/*.js && \
|
|
|
-git commit -e -m "version $version" && \
|
|
|
-git tag -a "v$version" -m "version $version" || true
|
|
|
+ # make a tagged detached commit of the dist files.
|
|
|
+ # no-verify (-n) avoids commit hooks.
|
|
|
+ if {
|
|
|
+ git checkout --detach --quiet && \
|
|
|
+ git add *.json && \
|
|
|
+ git add -f dist/*.js dist/*.css dist/locale/*.js && \
|
|
|
+ git commit -n -e -m "version $version" && \
|
|
|
+ git tag -a "v$version" -m "version $version"
|
|
|
+ }
|
|
|
+ then
|
|
|
+ success=1
|
|
|
+ fi
|
|
|
|
|
|
-# if failure building the commit, there will be leftover .json changes.
|
|
|
-# always discard. won't be harmful otherwise.
|
|
|
-git checkout "$orig_ref" -- *.json
|
|
|
+ # return to branch
|
|
|
+ git symbolic-ref HEAD "$orig_ref"
|
|
|
|
|
|
-# go back to the original branch.
|
|
|
-# need to reset so dist files are not staged.
|
|
|
-# this will be executed regardless of whether the commit was built correctly.
|
|
|
-git symbolic-ref HEAD "$orig_ref"
|
|
|
-git reset
|
|
|
+ # unstage ignored generated files or files leftover from failed git add's
|
|
|
+ git reset
|
|
|
+fi
|
|
|
|
|
|
-echo "DONE"
|
|
|
+if [[ "$success" = "1" ]]
|
|
|
+then
|
|
|
+ echo "Success."
|
|
|
+else
|
|
|
+ echo "Failure."
|
|
|
+ exit 1
|
|
|
+fi
|