home.


HockeyApp: Generating release notes from git

The problem with uploading to HockeyApp is the release notes are not automatically created.
 
And we can create them by looking at all the git commit logs since the last build.
 
For this to happen we need to know what the last commit was.
 
Although we can specify this in our upload, when we query the builds we can't get this information back. Instead, we'll add the commit SHA to the release notess.
 
Our plan will be
  1. Look at the app versions via HockeyApp's API
  2. Find the lastest version
  3. Look at the release notes that and retrieve our added commit SHA
  4. Make git output all our commit logs since then
  5. Make release notes out of that (including the current git commit)
Here's the entire commented shell script:

# We need an initial bullet point for our list of commit logs
echo -n "* "
# Get the latest app uploads
curl -H "X-HockeyAppToken: $HOCKEYAPP_TOKEN" \
"https://rink.hockeyapp.net/api/2/apps/YOUR_HOCKEYAPP_APP_ID/app_versions?page=1" | \
# Put every property on a separate line
sed 's/,/\n/g' | \
# Remove all the quotation marks
sed 's/"//g' | \
# Look at only the notes properties
grep notes | \
# Look at the first one, i.e. the latest app upload
head -n 1 | \
# Find the commit information at the bottom of the notes
sed -n 's/.*(commit:\([^)]*\)).*/\1/p' | \
# Let's find all the logs since that commit
xargs -I '{}' git log {}..HEAD --pretty=format:'%s' --no-merges | \
# Add a star to each newline to make the list
awk '$0="* "$0'
# The end of the revision log must have the latest commit
# This is so later we can do the above again
echo
echo -n "* (commit:" 
git rev-parse HEAD | xargs echo -n
echo -n ')'

And when we upload to HockeyApp, via travis-ci, we can include it like so:

- bash release_notes_for_hockeyapp.sh > release_notes
- >
  curl
  -F "status=2"
  -F "notify=1"
  -F "notes=<release_notes"
  -F "notes_type=0"
  -F "ipa=@app/build/outputs/apk/YOUR_APK.apk"
  -H "X-HockeyAppToken: $HOCKEYAPP_TOKEN"
  https://rink.hockeyapp.net/api/2/apps/upload


hockeyapp git travis-ci


Edit on Github!

comments powered by Disqus