Skip to content

Instantly share code, notes, and snippets.

@mikhail
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikhail/3d8aa4c7129d0fc246cf to your computer and use it in GitHub Desktop.
Save mikhail/3d8aa4c7129d0fc246cf to your computer and use it in GitHub Desktop.
Automatic Github changelog

Doing a proper version release requires documenting all the things you've changed. Frequently CHANGELOG.md is used for these purposes.

Unless you are maintaining that file throughout the changes it can become a hassle. Luckily you can leverage GitHub's issue tracking and PR system to manage that for you. If you use GitHub's milestones like you would versions then you have all the data there for you. However, you're stil left with the collection and formatting of the changes.

The script below automatically grabs that data for you and creates a markdown output. I've been successfully using it for our Kingpin project for several releases. Here's the sample use:

$ ./get_changelog Nextdoor/kingpin 0.2.0
## Version 0.2.0
 * #174: Add actor 'initialization context' support. ([@diranged])
 * #172: Add logger test in wait_for_task ([@siminm])
 * #171: Add aws.cloudformation.Create/Delete actors to resolve issue #48 ([@diranged])
 * #170: Missing unit test coverage in rightscale.api class.. ([@siminm])
 * #168: Use REQUIRED constant instead of None for options ([@siminm])
 * #166: Increase rollbar integration test timeout. ([@siminm])
 * #165: rightscale.Execute() actor should print out audit entries from execution. ([@siminm])
 * #164: Launch up to min count, instead of new min count. ([@siminm])
 * #163: rightscale.server_array.Launch actor always launches 'min_count' servers.. ([@siminm])
 * #162: Increase the timeout time for the Hipchat/Rollbar integration tests. ([@diranged])
 * #161: Track instances ([@siminm])
 * #160: RightScale returns 422 if Execute inputs are missing ([@siminm])
 * #159: Increase retry for launch_server_array ([@siminm])
 * #158: Retry current_instances call. ([@siminm])
 * #154: Convert dry actor to normal ([@siminm])
 * #153: Don't want for empty tasks. ([@siminm])
 * #152: Bump timeout for GenericHTTP Integration tests. ([@siminm])
 * #151: Add misc.Macro actor ([@siminm])
 * #150: Exponential Backoff for elb.WaitUntilHealthy Actor checks ([@siminm])
 * #147: Issue 141 ([@siminm])
 * #146: Retry recoverable errors in Hipchat. ([@siminm])
 * #144: kingpin.actors.test.integration_misc.IntegrationGenericHTTP needs longer timeouts ([@siminm])
 * #143: Add 'matrix' support to group.Sync/Async actors ([@diranged])
 * #142: actors.misc.Macro or add %file:///<name>% support to existing schema? ([@diranged])
 * #140: Add verbosity to Execute actor ([@siminm])
 * #138: Handle 504 Gateway Timeout in RightScale API Actions ([@diranged])
 * #137: Use the @retry decorator on librato.Annotation ([@cmclaughlin])
 * #136: Handle 'no' tasks passed into the wait_for_task() method ([@siminm])
 * #135: librato.Annotation actor should use @retry decorator ([@cmclaughlin])
 * #134: Add GenericHTTP to readme ([@siminm])
#!/usr/bin/env python
import requests
import sys
if len(sys.argv) > 2:
repo = sys.argv[1]
release = sys.argv[2]
else:
print 'Usage: %s <repo> <release #>' % sys.argv[0]
sys.exit(1)
ms = requests.get('https://api.github.com/repos/%s/milestones?state=all' % repo)
ms = ms.json()
ms = filter(lambda x: release in x['title'], ms)[0]
ms_number = ms['number']
issues = requests.get('https://api.github.com/repos/%s/issues?state=closed&milestone=%s' % (repo, ms_number))
issues = issues.json()
print '## Version %s' % release
for i in issues:
# User is either the assigned one, or if none, then the creator
user = i['assignee'] and i['assignee']['login'] or i['user']['login']
print ' * #%s: %s ([@%s])' % (i['number'], i['title'], user)
print ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment