Last active
September 29, 2017 02:52
-
-
Save dmitrymatveev/5fa01a9a30873c790487927805523519 to your computer and use it in GitHub Desktop.
Scripts to manage projects version updates
This file contains hidden or 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/bash | |
# ================================================================================================== | |
# Makes an archive of a pre-built distributable and | |
# using github REST apiV3 create a release on the current tag and uploads archive. | |
# This will assume the tag was created with the same name as current version in package.json | |
# | |
# Usage: | |
# github-deploy <archive file path> | |
# ================================================================================================== | |
if [ -z "${1}" ]; then | |
echo Aborting github release/upload | |
exit 0 | |
fi | |
PACKAGE_VERSION="v"$(cut -d "=" -f 2 <<< $(npm run env | grep "npm_package_version")) | |
REPO=$(cut -d ":" -f 2 <<< $(git remote get-url origin)) | |
USER=$(cut -d "/" -f 1 <<< $REPO) | |
REPO=$(cut -d "/" -f 2 <<< $REPO | cut -d "." -f 1) | |
cd ${2} | |
zip -r ./archive.zip * | |
# https://github.com/aktau/github-release | |
github-release release -u ${USER} -r ${REPO} -t ${PACKAGE_VERSION} | |
github-release upload -u ${USER} -r ${REPO} -t ${PACKAGE_VERSION} -n archive.zip -f ./archive.zip | |
# ================================================================================================== |
This file contains hidden or 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/bash | |
# ================================================================================================== | |
# Use generate-changelog npm module to update CHANGELOG file, push changes to master and bump | |
# version | |
# ================================================================================================== | |
case "${1}" in | |
major) | |
FLAG="-M" | |
VER="major" | |
;; | |
minor) | |
FLAG="-m" | |
VER="minor" | |
;; | |
patch) | |
FLAG="-p" | |
VER="patch" | |
;; | |
*) | |
echo "No version specified" | |
exit 1 | |
esac | |
# https://www.npmjs.com/package/changelog | |
changelog ${FLAG} && | |
git add CHANGELOG.md && | |
git commit -m 'updated CHANGELOG.md' && | |
npm version ${VER} && | |
git push origin && | |
git push origin --tags | |
# ================================================================================================== | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example package.json to go with the scripts
Prerequisites: