From 1cbf992d4fb61dff76824b852a254989225c28a3 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 7 Feb 2016 23:00:06 -0800 Subject: [PATCH] release.py: Automate GitHub release creation --- extra/release.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/extra/release.py b/extra/release.py index 302a5f3de..7bbc080c4 100755 --- a/extra/release.py +++ b/extra/release.py @@ -64,6 +64,9 @@ VERSION_LOCS = [ ), ] +GITHUB_USER = 'beetbox' +GITHUB_REPO = 'beets' + def bump_version(version): """Update the version number in setup.py, docs config, changelog, @@ -312,5 +315,40 @@ def publish(): subprocess.check_call(['twine', 'upload', path]) +@release.command() +def ghrelease(): + """Create a GitHub release using the `github-release` command-line + tool. + + Reads the changelog to upload from `changelog.md`. Uploads the + tarball from the `dist` directory. + """ + version = get_version(1) + tag = 'v' + version + + # Load the changelog. + with open(os.path.join(BASE, 'changelog.md')) as f: + cl_md = f.read() + + # Create the release. + subprocess.check_call([ + 'github-release', 'release', + '-u', GITHUB_USER, '-r', GITHUB_REPO, + '--tag', tag, + '--name', '{} {}'.format(GITHUB_REPO, version), + '--description', cl_md, + ]) + + # Attach the release tarball. + tarball = os.path.join(BASE, 'dist', 'beets-{}.tar.gz'.format(version)) + subprocess.check_call([ + 'github-release', 'upload', + '-u', GITHUB_USER, '-r', GITHUB_REPO, + '--tag', tag, + '--name', os.path.basename(tarball), + '--file', tarball, + ]) + + if __name__ == '__main__': release()