How to generate Release Notes / Changelog from Git Commits since last git tag?

release
release-notes
changelog

#1

Can be done with a simple Bash one-liner:

git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s"

Do you want to expose this as an environment variable, so that you can send it to Slack / attach as release notes? Just add a Script step to your workflow (after the git clone step of course :wink: ) with the content:

#!/bin/bash
set -ex

# fetch tags, to be sure we have all the require info
git fetch --tags

# collect the commits since the last tag
export GIT_RELEASE_NOTES="$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")"

# expose as env var for subsequent build steps
envman add --key GIT_RELEASE_NOTES --value "$GIT_RELEASE_NOTES"

After this Script step you can access the generated git release in the $GIT_RELEASE_NOTES env var, which can be used in other stepsโ€™ input, e.g. in a Slack message or similar.

The generated release note will look something like this (commit hash + first line of the commit message):

4909e29 test output format fix
de07079 release notes test script
8bff3f3 gitignore .bitrise.secrets.yml

Happy Building! :slight_smile:


Possible to get Release Notes into the Hockey App step?
#3

Note: if all you want to get is the last/current git commit message then you can use:

git log -1 --pretty=format:"%h %s"

instead of git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s".

Example:

#!/bin/bash
set -ex

# get only the last commit
export GIT_RELEASE_NOTES="$(git log -1 --pretty=format:"%h %s")"

# expose as env var for subsequent build steps
envman add --key GIT_RELEASE_NOTES --value "$GIT_RELEASE_NOTES"