Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
🔧 Add in the ability to turn off emojis when releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamieconnolly committed Jan 2, 2019
1 parent f2bb4a6 commit dbbda48
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions libexec/handles-release
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -e
cd "$(git rev-parse --show-toplevel 2>/dev/null)"

BRANCH="$(git symbolic-ref --short HEAD 2>/dev/null || true)"
USE_EMOJI="$(git config release.emoji || true)"
VERSION="$1"

if [ -z "$VERSION" ]; then
Expand Down Expand Up @@ -71,9 +72,13 @@ if [ -f "CHANGELOG.md" ] && ! grep -q "^# ${VERSION}" CHANGELOG.md &>/dev/null;
printf "# %s - %s\\n\\n" "$VERSION" "$(date +"%d %b %Y")" > CHANGELOG.tmp

if [ -n "$PREV_VERSION" ]; then
git log --reverse --no-merges --format='- %s' "$PREV_VERSION"..HEAD | grep -v ":bookmark:"
git log --reverse --no-merges --format='- %s' "$PREV_VERSION"..HEAD
else
echo "- :tada: Initial release"
if [ "$USE_EMOJI" == "true" ]; then
echo "- :tada: Initial release"
else
echo "- Initial release"
fi
fi >> CHANGELOG.tmp

if [ -s "CHANGELOG.md" ]; then
Expand All @@ -86,8 +91,14 @@ if [ -f "CHANGELOG.md" ] && ! grep -q "^# ${VERSION}" CHANGELOG.md &>/dev/null;
fi

if ! git diff-index --cached --quiet HEAD --; then
if [ "$USE_EMOJI" == "true" ]; then
COMMIT_MSG=":bookmark: Release ${VERSION}"
else
COMMIT_MSG="Release ${VERSION}"
fi

echo "==> Preparing release…"
if ! git commit -m ":bookmark: Release ${VERSION}" &>/dev/null; then
if ! git commit -m "$COMMIT_MSG" &>/dev/null; then
echo "!!! Error: failed to prepare release" >&2
exit 1
fi
Expand All @@ -102,8 +113,14 @@ if [ "$(git rev-list --count "${BRANCH}@{upstream}"..HEAD)" != "0" ]; then
fi

if [ "$BRANCH" == "master" ]; then
if [ "$USE_EMOJI" == "true" ]; then
RELEASE_MSG=":bookmark: Tag ${VERSION}"
else
RELEASE_MSG="Tag ${VERSION}"
fi

echo "==> Tagging release…"
if ! git tag -a -s "$VERSION" -m ":bookmark: Tag ${VERSION}" &>/dev/null; then
if ! git tag -a -s "$VERSION" -m "$RELEASE_MSG" &>/dev/null; then
echo "!!! Error: failed to tag release" >&2
exit 1
fi
Expand Down

0 comments on commit dbbda48

Please sign in to comment.