Last active
May 6, 2017 00:42
-
-
Save jgermade/d394e47341cf761286595ff4c865e2cd to your computer and use it in GitHub Desktop.
node-release.sh
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/sh | |
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
echo "npm version patch" | |
git pull --tags | |
npm version patch | |
git push origin ${GIT_BRANCH} | |
git push --tags | |
echo "npm publish" | |
npm publish | |
# PKG_NAME=$(node -e "console.log(require('./package.json').name);") | |
REPO_NAME=$(git config --get remote.origin.url | sed 's/.*\/\([^\.]*\).*/\1/') | |
REPO_OWNER=$(git config --get remote.origin.url | sed 's/.*:\([^\/]*\).*/\1/') | |
PKG_VERSION=$(node -e "console.log('v'+require('./package.json').version);") | |
echo "release ${REPO_OWNER}/${REPO_NAME}@${PKG_VERSION}" | |
curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${GITHUB_TOKEN}" \ | |
-d '{"tag_name": "'${PKG_VERSION}'", "target_commitish": "'${GIT_BRANCH}'", "name": "'${PKG_VERSION}'", "body": "", "draft": false, "prerelease": false}' \ | |
-w '%{url_effective}' "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment