Class: Radius::Toolbelt::ReleaseGithub

Inherits:
Object
  • Object
show all
Defined in:
lib/radius/toolbelt/release_github.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, token, tag_name, release_name, body, filenames) ⇒ ReleaseGithub

Returns a new instance of ReleaseGithub.



11
12
13
14
15
16
17
18
# File 'lib/radius/toolbelt/release_github.rb', line 11

def initialize(repo, token, tag_name, release_name, body, filenames)
  @repo = repo
  @tag_name = tag_name
  @release_name = release_name
  @body = body
  @filenames = filenames
  @token = token
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/radius/toolbelt/release_github.rb', line 10

def body
  @body
end

#filenamesObject (readonly)

Returns the value of attribute filenames.



10
11
12
# File 'lib/radius/toolbelt/release_github.rb', line 10

def filenames
  @filenames
end

#release_nameObject (readonly)

Returns the value of attribute release_name.



10
11
12
# File 'lib/radius/toolbelt/release_github.rb', line 10

def release_name
  @release_name
end

#repoObject (readonly)

Returns the value of attribute repo.



10
11
12
# File 'lib/radius/toolbelt/release_github.rb', line 10

def repo
  @repo
end

#tag_nameObject (readonly)

Returns the value of attribute tag_name.



10
11
12
# File 'lib/radius/toolbelt/release_github.rb', line 10

def tag_name
  @tag_name
end

#tokenObject (readonly)

Returns the value of attribute token.



10
11
12
# File 'lib/radius/toolbelt/release_github.rb', line 10

def token
  @token
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/radius/toolbelt/release_github.rb', line 20

def run
  puts "\nCreating draft release \"#{release_name}\" for repo \"#{repo}\"..."
  # create the release
  client = Octokit::Client.new(access_token: token)
  release = client.create_release(
    repo, tag_name,
    #target_commitish: tag_name,
    name: release_name,
    body: body,
    draft: true
  )

  # upload the files
  filenames.each do |filename|
    puts "Uploading #{filename}..."
    client.upload_asset release.url, filename
  end

  puts "\nRelease URL: #{release.html_url}"
  edit_url = release.html_url.gsub("/tag/", "/edit/")
  if block_given?
    yield({edit_url: edit_url})
  end
end