Skip to content

Instantly share code, notes, and snippets.

@sis0k0
Created July 5, 2017 12:08
Show Gist options
  • Save sis0k0/2652dfe8c8b71bf1fc517179db7b35d6 to your computer and use it in GitHub Desktop.
Save sis0k0/2652dfe8c8b71bf1fc517179db7b35d6 to your computer and use it in GitHub Desktop.
simple bash script for npm packages publish prepare
#!/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