Last active
July 17, 2017 21:29
-
-
Save sylvaindethier/f27c97cd00e5b7c74aa7 to your computer and use it in GitHub Desktop.
NPM Release
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
#!/bin/bash | |
set -e | |
# -e: Exit immediately if a pipeline [...] returns a non-zero status. | |
# @see: https://www.gnu.org/software/bash/manual/bashref.html#The-Set-Builtin-1 | |
## prevent runing script outside the repo root | |
if ! [ -e scripts/release.sh ]; then | |
echo >&2 "Please run scripts/release.sh from the repo root" | |
exit 1 | |
fi | |
## run the build | |
npm run build | |
## get the current version from package | |
current_version=$(node -p "require('./package').version") | |
## read the version update type | |
printf "Current version is '$current_version'" | |
printf "Update type ? <version> | (pre)major | (pre)minor | (pre)patch | prerelease | from-git" | |
read update_type | |
## add and commit unstaged changes | |
git add --all | |
git commit --allow-empty -am "Update $update_type from $current_version" | |
## update package version (disable git-tag-version, will be done after) | |
version=$(npm --no-git-tag-version version $update_type) | |
## create tag version | |
git tag -a "$version" -m "version $version" | |
## push to origin with tag | |
git push --follow-tag origin master | |
## publish to npm | |
npm publish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment