Created
October 8, 2021 15:18
-
-
Save robcee/e39bc3a00ada46f4dc1349238ab00c00 to your computer and use it in GitHub Desktop.
Script to generate changelogs from git commit record
This file contains 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 | |
# | |
# 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