release.py: Automate GitHub release creation

This commit is contained in:
Adrian Sampson 2016-02-07 23:00:06 -08:00
parent df07d83a6d
commit 1cbf992d4f

View file

@ -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()