Skip to content

Commit

Permalink
release script
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Jan 2, 2022
1 parent 778964a commit ebbc89c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"t:debug": "DEBUG=jsonrpc-ts-client npm test",
"lint": "npm run tsc:check && eslint .",
"prepare": "npm run build",
"tsc:check": "tsc --noEmit"
"tsc:check": "tsc --noEmit",
"release": "bash scripts/release.sh"
},
"husky": {
"hooks": {
Expand Down
14 changes: 10 additions & 4 deletions scripts/release.sh
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

0 comments on commit ebbc89c

Please sign in to comment.