Skip to content

Instantly share code, notes, and snippets.

@robcee
Created October 8, 2021 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robcee/e39bc3a00ada46f4dc1349238ab00c00 to your computer and use it in GitHub Desktop.
Save robcee/e39bc3a00ada46f4dc1349238ab00c00 to your computer and use it in GitHub Desktop.
Script to generate changelogs from git commit record
#!/bin/bash
#
# fail if any commands fails
set -e
# debug log
set -x
if [ ! -e ${env.APP_TAG_NAME} ]
then
echo "${env.APP_TAG_NAME} not found. Exiting..."
exit 1
fi
APP_TAG=\$(cat ${env.APP_TAG_NAME})
# fetch tags, to be sure we have all the require info
git fetch --tags
GIT_CHANGELOG_HEADER=$(echo "## Changelog")
# collect the commits since the last tag
LAST_TAG=$(git describe --tags --match "native*" --abbrev=0)
GIT_CHANGELOG=\$(git log --decorate=full --grep="\[Apps\]" --notes --merges $LAST_TAG..HEAD | grep "\[Apps\]" | sed s/.Apps./\*/)
GIT_CHANGELOG=\$(echo -e "$GIT_CHANGELOG_HEADER\n$GIT_CHANGELOG")
GIT_TRUNCATED_CHANGELOG=\$(echo "$GIT_CHANGELOG" | head -c 5000)
# save changelog as file
echo "$GIT_TRUNCATED_CHANGELOG" | tee changelog_android.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment