Skip to content

Instantly share code, notes, and snippets.

@michaelstonis
Last active June 29, 2018 23:12
Show Gist options
  • Save michaelstonis/ee56f1c0da8d1dc3f9157642303fee4b to your computer and use it in GitHub Desktop.
Save michaelstonis/ee56f1c0da8d1dc3f9157642303fee4b to your computer and use it in GitHub Desktop.
VSTS Bash Script that builds release notes for the last weeks worth of commits
#!/bin/bash
# Generates changelog day by day
# Based on sample from https://stackoverflow.com/questions/2976665/git-changelog-day-by-day
BRANCH=${BUILD_SOURCEBRANCHNAME}
FILE=${BUILD_STAGINGDIRECTORY}/releasenotes.md
TMP=$(mktemp)
TODAY=$(date +%Y-%m-%d)
YESTERDAY=$(date -v-1d +%Y-%m-%d)
THIS_WEEK=$(date -v-7d +%Y-%m-%d)
for i in "$@"
do
case $i in
-f=*|--file=*)
FILE="${i#*=}"
;;
-b=*|--branch=*)
BRANCH="${i#*=}"
;;
*)
# unknown option
;;
esac
done
{
echo **TODAY '('$TODAY')'**
git log --no-merges --since="$TODAY 00:00:00" --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo
GIT_PAGER=cat git log --no-merges --format=" * %s" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
echo
done
} > ${TMP}
{
echo
echo **LAST WEEK '(thru '$THIS_WEEK')'**
git log --no-merges --before="$TODAY 00:00:00" --since="$THIS_WEEK 00:00:00" --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo
echo *$DATE*
echo
GIT_PAGER=cat git log --no-merges --format=" * %s" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
echo
done
} >> ${TMP}
head -c 5000 ${TMP} > ${FILE}
rm ${TMP}
@michaelstonis
Copy link
Author

Add a new Bash Script Task to your build in VSTS
image

Set it up to be an Inline script
image

Paste in the code above.

This will add a new file named releasenotes.md to your build artifacts.

It is truncated at 5000 characters to allow it to be used with AppCenter.ms

@nilofer
Copy link

nilofer commented Jun 29, 2018

Hey @michaelstonis - this is really cool! I'm a Program Manager on the App Center team. We have a repo for build script examples. Feel free to make a pull request there with this script if you're up to sharing 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment