-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e70a35
commit 92ffcb5
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/bin/bash | ||
|
||
PROJECT_NAME='dash-shaka-playback' | ||
CDN_PATH="gh/clappr/dash-shaka-playback@latest/dist/$PROJECT_NAME.min.js" | ||
|
||
update_dependencies() { | ||
echo 'updating dependencies' && | ||
yarn install | ||
} | ||
|
||
update_version() { | ||
current_tag=$(git describe --abbrev=0 --tags master) && | ||
echo 'bump from '$current_tag' to '$1 && | ||
sed -i ".bkp" "s/\(version\":[ ]*\"\)$current_tag/\1$1/" package.json | ||
} | ||
|
||
build() { | ||
echo "building $PROJECT_NAME.js" && | ||
yarn build && | ||
echo "building $PROJECT_NAME.min.js" && | ||
yarn release | ||
} | ||
|
||
run_tests() { | ||
yarn lint | ||
} | ||
|
||
make_release_commit() { | ||
git add package.json yarn.lock && | ||
git commit -m 'chore(package): bump version' && | ||
git tag -m "$1" $1 | ||
} | ||
|
||
git_push() { | ||
echo 'pushing to github' | ||
git push origin master --tags | ||
} | ||
|
||
npm_publish() { | ||
npm publish | ||
} | ||
|
||
purge_cdn_cache() { | ||
echo 'purging cdn cache' | ||
curl -q "http://purge.jsdelivr.net/$CDN_PATH" | ||
} | ||
|
||
main() { | ||
npm whoami | ||
if (("$?" != "0")); then | ||
echo "you are not logged into npm" | ||
exit 1 | ||
fi | ||
update_dependencies && | ||
update_version $1 && | ||
build | ||
if (("$?" != "0")); then | ||
echo "something failed during dependency update, version update, or build" | ||
exit 1 | ||
fi | ||
run_tests | ||
if (("$?" == "0")); then | ||
make_release_commit $1 && | ||
git_push && | ||
npm_publish && | ||
purge_cdn_cache && | ||
exit 0 | ||
|
||
echo "something failed" | ||
exit 1 | ||
else | ||
echo "you broke the tests. fix it before bumping another version." | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [ "$1" != "" ]; then | ||
main $1 | ||
else | ||
echo "Usage: bump [new_version]" | ||
fi |