bitcore/scripts/tag-and-release.sh

254 lines
4.5 KiB
Bash
Raw Permalink Normal View History

2017-10-09 15:07:41 -07:00
#!/bin/bash
set -e
2017-10-12 07:19:24 -07:00
######### Adjust these variables as needed ################
insightApiDir="${HOME}/source/insight-api"
insightUIDir="${HOME}/source/insight-ui"
bitcoreDir="${HOME}/source/bitcore"
2017-11-05 15:44:09 -08:00
bitcoreNodeDir="${HOME}/source/bitcore-node"
2017-10-12 07:19:24 -07:00
###########################################################
2017-10-09 15:07:41 -07:00
# given a string tag, make signed commits, push to relevant repos, create signed tags and publish to npm
bump_version () {
2017-11-13 11:28:07 -08:00
sed -i '' -e "s/\"version\"\: .*$/\"version\"\: \"${shortTag}\",/g" package.json
2017-10-09 15:07:41 -07:00
}
set_deps () {
2017-11-13 11:28:07 -08:00
sed -i '' -e "s/\"bitcore-node\"\: .*$/\"bitcore-node\"\: \"${shortTag}\",/g" package.json
sed -i '' -e "s/\"insight-api\"\: .*$/\"insight-api\"\: \"${shortTag}\",/g" package.json
sed -i '' -e "s/\"insight-ui\"\: .*$/\"insight-ui\"\: \"bitpay\/insight\#${tag}\"/g" package.json
2017-10-09 15:07:41 -07:00
}
tag="${1}"
shortTag=`echo "${tag}" | cut -c 2-`
if [ -z "${tag}" ]; then
echo ""
echo "No tag given, exiting."
exit 1
fi
#############################################
# bitcore-node
#############################################
2017-10-12 15:02:56 -07:00
function bitcoreNode() {
echo ""
echo "Starting with bitcore-node..."
sleep 2
pushd "${bitcoreNodeDir}"
2017-10-09 15:07:41 -07:00
2017-10-20 10:22:55 -07:00
sudo rm -fr node_modules
2017-10-12 15:02:56 -07:00
bump_version
npm install
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
git add .
git diff --staged
echo ""
echo -n 'Resume?: (Y/n): '
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
read ans
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
if [ "${ans}" == 'n' ]; then
echo "Exiting as requested."
exit 0
fi
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Committing changes for bitcore-node..."
sleep 2
git commit -S
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing changes to Github..."
git push origin master && git push upstream master
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Signing a tag"
git tag -s "${tag}" -m"${tag}"
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing the tag to upstream..."
git push upstream "${tag}"
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Publishing to npm..."
npm publish --tag beta
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
popd
}
2017-10-09 15:07:41 -07:00
#############################################
# insight-api
#############################################
2017-10-12 15:02:56 -07:00
function insightApi() {
echo ""
echo "Releasing insight-api..."
sleep 2
pushd "${insightApiDir}"
2017-10-09 15:07:41 -07:00
2017-10-20 10:22:55 -07:00
sudo rm -fr node_modules
2017-10-12 15:02:56 -07:00
bump_version
npm install
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
git add .
git diff --staged
echo ""
echo -n 'Resume?: (Y/n): '
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
read ans
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
if [ "${ans}" == 'n' ]; then
echo "Exiting as requested."
exit 0
fi
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Committing changes for insight-api..."
sleep 2
git commit -S
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing changes to Github..."
git push origin master && git push upstream master
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Signing a tag"
git tag -s "${tag}" -m"${tag}"
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing the tag to upstream..."
git push upstream "${tag}"
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Publishing to npm..."
npm publish --tag beta
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
popd
}
2017-10-09 15:07:41 -07:00
#############################################
# insight-ui
#############################################
2017-10-12 15:02:56 -07:00
function insightUi() {
echo ""
echo "Releasing insight-ui..."
sleep 2
pushd "${insightUIDir}"
2017-10-09 15:07:41 -07:00
2017-10-20 10:22:55 -07:00
sudo rm -fr node_modules
2017-10-12 15:02:56 -07:00
bump_version
npm install
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
git add .
git diff --staged
echo ""
echo -n 'Resume?: (Y/n): '
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
read ans
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
if [ "${ans}" == 'n' ]; then
echo "Exiting as requested."
exit 0
fi
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Committing changes for insight-ui..."
sleep 2
git commit -S
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing changes to Github..."
git push origin master && git push upstream master
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Signing a tag"
git tag -s "${tag}" -m"${tag}"
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing the tag to upstream..."
git push upstream "${tag}"
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Publishing to npm..."
npm publish --tag beta
2017-10-09 15:10:01 -07:00
2017-10-12 15:02:56 -07:00
popd
}
2017-10-09 15:07:41 -07:00
#############################################
# bitcore
#############################################
2017-10-12 15:02:56 -07:00
function bitcore() {
echo ""
echo "Releasing bitcore..."
sleep 2
pushd "${bitcoreDir}"
2017-10-09 15:07:41 -07:00
2017-10-20 10:22:55 -07:00
sudo rm -fr node_modules
2017-10-12 15:02:56 -07:00
bump_version
set_deps
npm install
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
git add .
git diff --staged
echo ""
echo -n 'Resume?: (Y/n): '
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
read ans
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
if [ "${ans}" == 'n' ]; then
echo "Exiting as requested."
exit 0
fi
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Committing changes for bitcore..."
sleep 2
git commit -S
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing changes to Github..."
git push origin master && git push upstream master
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Signing a tag"
git tag -s "${tag}" -m"${tag}"
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Pushing the tag to upstream..."
git push upstream "${tag}"
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
echo ""
echo "Publishing to npm..."
npm publish --tag beta
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
popd
2017-10-09 15:07:41 -07:00
2017-10-12 15:02:56 -07:00
echo "Completed releasing tag: ${tag}"
}
2017-10-09 15:07:41 -07:00
2017-10-12 16:15:28 -07:00
echo ""
echo "Tagging with ${tag}..."
echo "Assuming projects at ${HOME}/source..."
releases="${2}"
2017-10-12 15:02:56 -07:00
if [ -z "${releases}" ]; then
2017-10-20 10:22:55 -07:00
bitcoreNode
2017-10-12 15:02:56 -07:00
insightApi
insightUi
bitcore
else
eval "${releases}"
fi
2017-10-09 15:07:41 -07:00