Skip to content

Commit

Permalink
Edit release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
j0057 committed Aug 13, 2014
1 parent 6c1ec40 commit 1ed64ae
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions github_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import json
import os
import sys
import tempfile

import requests
from requests import request

Expand Down Expand Up @@ -93,6 +95,23 @@ def gh_release_publish(repo_name, tag_name):
def gh_release_unpublish(repo_name, tag_name):
patch_release(repo_name, tag_name, draft=True)

def gh_release_notes(repo_name, tag_name):
release = get_release_info(repo_name, tag_name)
(_, filename) = tempfile.mkstemp(suffix='.md')
try:
if release['body']:
with open(filename, 'w+b') as f:
f.write(release['body'])
ret = os.system('{0} {1}'.format(os.environ['EDITOR'], filename))
if ret: raise Exception('{0} returned exit code {1}'.format(os.environ['EDITOR'], ret))
with open(filename, 'rb') as f:
body = f.read()
if release['body'] == body:
return
patch_release(repo_name, tag_name, body=body)
finally:
os.remove(filename)

def gh_asset_upload(repo_name, tag_name, filename):
release = get_release_info(repo_name, tag_name)
with open(filename) as f:
Expand Down Expand Up @@ -139,6 +158,7 @@ def gh_release():
'delete': gh_release_delete, # gh-release j0057/iplbapi delete 1.4.4
'publish': gh_release_publish, # gh-release j0057/iplbapi publish 1.4.4
'unpublish': gh_release_unpublish, # gh-release j0057/iplbapi unpublish 1.4.4
'release-notes': gh_release_notes, # gh-release j0057/iplbapi release-notes 1.4.3
}
return handle_http_error(lambda: commands[args.pop(1)](*args))

Expand Down

0 comments on commit 1ed64ae

Please sign in to comment.