-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrelease_body.rb
More file actions
27 lines (21 loc) · 864 Bytes
/
release_body.rb
File metadata and controls
27 lines (21 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env ruby
require 'optparse'
require 'octokit'
options = {}
OptionParser.new do |opt|
opt.on('-s', '--secret SECRET', 'GitHub access token') { |o| options[:secret] = o }
opt.on('-b', '--body BODY', 'Release body') { |o| options[:body] = o }
opt.on('-t', '--tag TAG', 'Tag name') { |o| options[:tag_name] = o }
end.parse!
client = Octokit::Client.new(:access_token => options[:secret])
user = client.user
user.login
unless client.scopes.include? 'public_repo' or client.scopes.include? 'repo'
raise Error, "Insufficient permissions. Make sure your token contains the repo or public_repo scope."
end
releases = client.releases(ENV['TRAVIS_REPO_SLUG'])
releases.each do |release|
if release.tag_name == options[:tag_name]
client.update_release(release.rels[:self].href, { :name => options[:tag_name], :body => options[:body] })
end
end