Class: CaptiveRelease::GithubRelease
- Inherits:
-
Object
- Object
- CaptiveRelease::GithubRelease
- Includes:
- GithubHttp
- Defined in:
- lib/captive_release/github_release.rb
Constant Summary collapse
- GITHUB_API =
"https://api.github.com"
Constants included from GithubHttp
CaptiveRelease::GithubHttp::MAX_REDIRECTS
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(version:, body:, remote_url:, token:) ⇒ GithubRelease
constructor
A new instance of GithubRelease.
Methods included from GithubHttp
Constructor Details
#initialize(version:, body:, remote_url:, token:) ⇒ GithubRelease
Returns a new instance of GithubRelease.
17 18 19 20 21 22 |
# File 'lib/captive_release/github_release.rb', line 17 def initialize(version:, body:, remote_url:, token:) @version = version @body = body @remote_url = remote_url @token = token end |
Class Method Details
.create(version:, body:, remote_url:, token:) ⇒ Object
13 14 15 |
# File 'lib/captive_release/github_release.rb', line 13 def self.create(version:, body:, remote_url:, token:) new(version: version, body: body, remote_url: remote_url, token: token).create end |
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/captive_release/github_release.rb', line 24 def create owner, repo = parse_remote(@remote_url) uri = URI("#{GITHUB_API}/repos/#{owner}/#{repo}/releases") payload = JSON.generate({ "tag_name" => "v#{@version}", "name" => "v#{@version}", "body" => @body.empty? ? "_No commits since last release._" : @body, "draft" => false, "prerelease" => false, }) response = github_post(uri, @token, payload) data = JSON.parse(response.body) raise "GitHub API error (#{response.code}): #{data["message"]}" unless response.code == "201" data["html_url"] end |