From ebbc89cc250de8e647905475a934b4a2144a76ab Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Sun, 2 Jan 2022 13:35:31 -0600 Subject: [PATCH] release script --- package.json | 3 ++- scripts/release.sh | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2b7695d..9561b54 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/scripts/release.sh b/scripts/release.sh index e4400c3..8b3c94b 100644 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,4 +1,6 @@ #!/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' @@ -6,16 +8,20 @@ if [[ "$BRANCH" != "main" ]]; then 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 \ No newline at end of file