-
-
Save vchimev/2aa8ce0dd65ba85cdd22e1b1c8572bac to your computer and use it in GitHub Desktop.
simple bash script for npm packages publish prepare
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 | |
# release defaults to patch (last number in semver) | |
RELEASE="patch" && [ -n "$1" ] && RELEASE=$1 | |
# cut the release | |
VERSION=$(npm --no-git-tag-version version $RELEASE | sed 's/v//') | |
git add package.json | |
git commit -m "release: cut the $VERSION release" | |
# generate changelog | |
{ | |
conventional-changelog -p angular -i CHANGELOG.md -s | |
} || { | |
echo -e "\033[1;91m Please install conventional-changelog-cli for the CHANGELOG" | |
echo -e "\033[1;95m npm i -g conventional-changelog-cli" | |
exit 1 | |
} | |
# replace v1.2.3 with 1.2.3 in CHANGELOG to follow semver 2.0 | |
sed -i "s/...v$VERSION/...$VERSION/g" CHANGELOG.md | |
git add CHANGELOG.md | |
git commit -m "docs: add changelog for $VERSION" | |
# tag the release | |
git tag $VERSION | |
git tag -l | |
echo -e "\033[1;92m You are ready to publish!" | |
echo -e "\033[1;95m git push" | |
echo -e "\033[1;95m git push --tags" | |
echo -e "\033[1;95m npm publish" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment