Skip to content

Commit

Permalink
Cleanup release script (scripts/release.sh). Closes #218
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuswestin committed Jun 20, 2017
1 parent 261b74a commit 897bfec
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 9 deletions.
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

5 changes: 1 addition & 4 deletions package.json
Expand Up @@ -4,10 +4,7 @@
"description": "A localStorage wrapper for all browsers without using cookies or flash. Uses localStorage, globalStorage, and userData behavior under the hood",
"main": "dist/store.legacy.js",
"scripts": {
"test": "make test",
"preversion": "bash scripts/release-prompt.sh",
"version": "make build && git add -A dist",
"postversion": "git push && git push --tags"
"test": "make test"
},
"repository": {
"type": "git",
Expand Down
4 changes: 0 additions & 4 deletions scripts/release-prompt.sh

This file was deleted.

62 changes: 62 additions & 0 deletions scripts/release.sh
@@ -0,0 +1,62 @@
#!/bin/bash
set -e


cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # scripts/
cd ../ # store.js project root

VERSION=$1
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$VERSION is not a valid semver (e.g 2.1.3)"
exit -1
fi

GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
if [ "$GIT_BRANCH" != "master" ]; then
echo "release.sh must be called from branch master (current: $GIT_BRANCH)"
exit -1
fi

echo
echo "> Bump package.json version:"
echo
sed -E s/'"version"\: "[0-9]+\.[0-9]+\.[0-9]+"'/'"version"\: "'$VERSION'"'/ package.json \
> /tmp/package.json && \
mv /tmp/package.json package.json
cat package.json | grep $VERSION -C 1

echo
echo "> Bump store-engine.js version:"
echo
sed -E s/"version\: '[0-9]+\.[0-9]+\.[0-9]+'"/"version\: '$VERSION'"/ src/store-engine.js \
> /tmp/store-engine.js && \
mv /tmp/store-engine.js src/store-engine.js
cat src/store-engine.js | grep $VERSION -C 1

echo
while true; do
read -p "> Ready to build, commit, tag and release v$VERSION? (y/n): " yn
case $yn in
[Yy]* ) break;;
[NnQq]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done

echo
echo "> Build dists"
node scripts/compile-builds.js

echo
echo "> git commit/push/tag/push --tags"
set -x
git add dist/* package.json src/store-engine.js
git commit -m "v$VERSION"
git push $ORIGIN $BRANCH
git tag -a "v$VERSION" -m "Tag v$VERSION"
git push --tags
set +x

echo
echo "> npm publish"
npm publish

0 comments on commit 897bfec

Please sign in to comment.