-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
2 changed files
with
12 additions
and
5 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
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 |
---|---|---|
@@ -1,21 +1,27 @@ | ||
#!/bin/bash | ||
VERSION="${1:-"patch"}" # major | minor | patch | ||
|
||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
if [[ "$BRANCH" != "main" ]]; then | ||
echo '--> Only execute this on main branch' | ||
exit 0 | ||
fi | ||
|
||
# make sure you don't tag an old commit | ||
git pull --ff-only | ||
git pull --ff-only && | ||
|
||
# don't create git tag here, it will automatically be created in the next step | ||
npm version --no-git-tag-version patch -m "Upgrade to %s" | ||
npm version "$VERSION" -f -m "Upgrade to %s" && | ||
|
||
# push after versioning (tags will be pushed in next step) | ||
# (also relevant: `postVersion:` key: https://docs.npmjs.com/cli/v7/commands/npm-version) | ||
git push && | ||
|
||
# github will automatically create a tag when you create a release | ||
# github will automatically create and push the tag when you create a release | ||
tag="v$(node -p "require('./package.json').version")" | ||
gh release create \ | ||
"$tag" \ | ||
--title "$tag" \ | ||
--notes "releases $tag" | ||
--notes "releases $tag" && | ||
|
||
npm publish |