Skip to content

Instantly share code, notes, and snippets.

@mseijas
Last active October 22, 2016 18:40
Show Gist options
  • Save mseijas/7b4bfccc286e121d0ae8c3500d6b0c50 to your computer and use it in GitHub Desktop.
Save mseijas/7b4bfccc286e121d0ae8c3500d6b0c50 to your computer and use it in GitHub Desktop.
#!/bin/bash
# fail if any commands fails
set +e
# debug log
# set -x
lastTag="$(git describe --tags --abbrev=0)"
set -e
if [ -z "${lastTag}" ]; then
changelog="$(git log --pretty="• %s %gn" --abbrev-commit --no-merges --reverse)"
else
changelog="$(git log "${lastTag}"..HEAD --pretty="• %s %gn" --abbrev-commit --no-merges --reverse)"
fi
if [ -z "${changelog}" ]; then
echo " [!] Unable to retrieve Git Changelog"
exit 1
else
envman add --key GIT_CHANGELOG --value "${changelog}"
echo "Changelog: ${changelog}"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment