Class: Releaser

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/releaser.rb

Overview

TODO: extract to gem?

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Releaser

Returns a new instance of Releaser


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/tasks/releaser.rb', line 4

def initialize(options = {})
  @project_name = options.delete(:project_name) do
    fail "project_name is needed!"
  end

  @gem_name = options.delete(:gem_name) do
    fail "gem_name is needed!"
  end

  @github_repo = options.delete(:github_repo) do
    fail "github_repo is needed!"
  end

  @version = options.delete(:version) do
    fail "version is needed!"
  end
end

Instance Method Details

#fullObject


22
23
24
25
# File 'lib/tasks/releaser.rb', line 22

def full
  rubygems
  github
end

#githubObject


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/tasks/releaser.rb', line 40

def github
  tag_name = "v#{@version}"

  require "gems"

  _verify_released
  _verify_tag_pushed

  require "octokit"
  gh_client = Octokit::Client.new(netrc: true)

  gh_release = _detect_gh_release(gh_client, tag_name, true)
  return unless gh_release

  STDOUT.puts "Draft release for #{tag_name}:\n"
  STDOUT.puts gh_release.body
  STDOUT.puts "\n-------------------------\n\n"

  _confirm_publish

  return unless _update_release(gh_client, gh_release, tag_name)

  gh_release = _detect_gh_release(gh_client, tag_name, false)

  _success_summary(gh_release, tag_name)
end

#rubygemsObject


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tasks/releaser.rb', line 27

def rubygems
  input = nil
  loop do
    STDOUT.puts "Release #{@project_name} #{@version} to RubyGems? (y/n)"
    input = STDIN.gets.chomp.downcase
    break if %w(y n).include?(input)
  end

  exit if input == "n"

  Rake::Task["release"].invoke
end