Skip to content

Commit

Permalink
New: Add script to upgrade box-annotations version in Preview (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum authored Nov 6, 2017
1 parent e78cf06 commit 7de9e4a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
69 changes: 69 additions & 0 deletions build/upgrade_annotations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

export NODE_PATH=$NODE_PATH:./node_modules

update_version() {
CURRENT_VERSION="$(cat package.json | grep box-annotations | sed 's/.*\^\(.*\)\".*/\1/')";
LATEST_VERSION="$(npm show box-annotations version)";

yarn add box-annotations@^$LATEST_VERSION

UPDATED_VERSION="$(cat package.json | grep box-annotations | sed 's/.*\^\(.*\)\".*/\1/')";

if [ $UPDATED_VERSION == $LATEST_VERSION ]; then
echo "----------------------------------------------------------------------"
echo "Successfully upgraded from $CURRENT_VERSION to $UPDATED_VERSION"
echo "----------------------------------------------------------------------"
else
echo "----------------------------------------------------------------------"
echo "Error: Failed to upgrade to $CURRENT_VERSION"
echo "----------------------------------------------------------------------"
fi
}

get_changelog() {
CHANGELOG="$(curl https://raw.githubusercontent.com/box/box-annotations/master/CHANGELOG.md | awk '/\#/{f=1} f{print; if (/\<a/) exit}' | grep . | sed 's/\<a.*//')";
}


push_to_github() {
# Add new files
git add . && git commit -m "Update: box-annotations to v$UPDATED_VERSION" -m "https://github.com/box/box-annotations/releases" -m "$CHANGELOG"

# Push commit to GitHub
if git push origin -f --no-verify; then
echo "----------------------------------------------------------------------"
echo "Pushed commit to git successfully"
echo "----------------------------------------------------------------------"
else
echo "----------------------------------------------------------------------"
echo "Error while pushing commit to git"
echo "----------------------------------------------------------------------"
return 1
fi
}

upgrade_box_annotations() {
# Bump the version number
update_version || return 1

# Update changelog
get_changelog || return 1

# Push to GitHub
push_to_github || return 1

return 0
}

# Execute this entire script
if ! upgrade_box_annotations; then
echo "----------------------------------------------------------------------"
echo "Error while upgrading box-annotations to latest version!"
echo "----------------------------------------------------------------------"

echo "----------------------------------------------------------------------"
echo "Cleaning workspace by checking out master and removing tags"
echo "----------------------------------------------------------------------"
exit 1
fi
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"release": "yarn run clean && yarn run build-rb && yarn run lint && yarn run test && yarn run prod",
"test": "NODE_ENV=test ./node_modules/.bin/karma start build/karma.conf.js",
"upgrade-pdfjs": "./build/upgrade_pdfjs.sh && ./build/minify_pdfjs.sh",
"upgrade-annotations": "./build/upgrade_annotations.sh",
"watch": "BABEL_ENV=dev NODE_ENV=dev ./node_modules/.bin/webpack --watch --progress --colors --config build/webpack.config.js",
"major": "./build/release.sh -m",
"minor": "./build/release.sh -n",
Expand Down

0 comments on commit 7de9e4a

Please sign in to comment.