Skip to content

Instantly share code, notes, and snippets.

@jcreamer898
Created March 5, 2019 16:23
Show Gist options
  • Save jcreamer898/086195795e18c9c18a67a7b97dd637a6 to your computer and use it in GitHub Desktop.
Save jcreamer898/086195795e18c9c18a67a7b97dd637a6 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
# Leaving this in for reference
# -c|--config-file)
# DRY_RUN=$2
# shift
# ;;
--debug)
DEBUG=TRUE
set -x
shift # past argument
;;
--dry-run)
DRY_RUN=TRUE
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}"
VERSION=${POSITIONAL[0]}
PACKAGE=${POSITIONAL[1]}
if [ ! -z "$(git status ./packages --porcelain)" ]; then
echo "You have uncommitted changes in $PACKAGE. Commit them before running the version script."
exit 1
fi
VERSION_OUTPUT=$(bolt w $PACKAGE exec -- npm version $VERSION)
NEXT_VERSION=$(echo $VERSION_OUTPUT | grep -oE "v([0-9\.]+)$")
TAG="$PACKAGE@$NEXT_VERSION"
if [ -z ${DRY_RUN+x} ]; then
git checkout -b release-$TAG
bolt w $PACKAGE exec -- git add package.json
git commit --no-verify -m "Version $TAG"
# TODO: Maybe tag?
# git tag $TAG
echo 'Pushing branch to remote'
git push origin release-$TAG
else
echo "Would be creating tag... $TAG"
COMMITS=$(git log master..HEAD --pretty=format:'* %h%s')
CHANGELOG_MESSAGE=$(cat <<EOF
$COMMITS
EOF
)
echo "$CHANGELOG_MESSAGE" > CHANGELOG.md
git checkout packages
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment