Adding a Changelog to GitHub Releases with Travis

by on under travis
1 minute read

You can add a changelog to your GitHub releases with very little work, just by grabbing the commit messages between the previous tag and the current one. This makes the process entirely dynamic, with no extra management required.

You’ll need something like this in your .travis.yml:

before_deploy:
  - export CHANGELOG=$(git log $(git describe --abbrev=0 --tags "${TRAVIS_TAG}^")..$TRAVIS_TAG --pretty=format:'<li> <a href="http://github.com/your-username/your-project/commit/%H">view commit &bull;</a> %s</li> ' --reverse | while read line; do echo -n "$line "; done
)
deploy:
  provider: releases
  skip_cleanup: true
  api_key: ...
  name: "My Program $TRAVIS_TAG"
  body: ${CHANGELOG}
  on:
    tags: true

When your build is done, you should see:

Release

github, git, releases, changelog
comments powered by Disqus