Ver código fonte

improve build scripts

Adam Shaw 9 anos atrás
pai
commit
f6d4be4ad2
2 arquivos alterados com 59 adições e 31 exclusões
  1. 41 28
      bin/build-release.sh
  2. 18 3
      bin/publish-release.sh

+ 41 - 28
bin/build-release.sh

@@ -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

+ 18 - 3
bin/publish-release.sh

@@ -19,10 +19,25 @@ fi
 git push
 git push origin "v$version"
 
-# temporarily checkout the tag's commit for publishing to NPM
+# save reference to current branch
 current_branch=$(git symbolic-ref --quiet --short HEAD)
+
+success=0
+
+# temporarily checkout the tag's commit, publish to NPM
 git checkout --quiet "v$version"
-npm publish
+if npm publish
+then
+	success=1
+fi
+
+# return to branch
 git checkout --quiet "$current_branch"
 
-echo "DONE"
+if [[ "$success" = "1" ]]
+then
+	echo "Success."
+else
+	echo "Failure."
+	exit 1
+fi