Class: KnifeCommunity::CommunityRelease

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/community_release.rb

Instance Method Summary collapse

Instance Method Details

#runObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/chef/knife/community_release.rb', line 68

def run
  self.setup

  ui.msg "Starting to validate the envrionment before changing anything..."
  validate_cookbook_exists
  validate_repo
  validate_repo_clean
  validate_version_sanity
  validate_no_existing_tag(get_tag_string)
  # TODO: skip next step if --no-git-push is provided
  validate_target_remote_branch

  ui.msg "All validation steps have passed, making changes..."
  set_new_cb_version
  commit_new_cb_version
  tag_new_cb_version(get_tag_string)

  if config[:git_push]
    git_push_commits
    git_push_tags
  end

  if config[:site_share]
    confirm_share_msg  = "Shall I release version #{@version} of the"
    confirm_share_msg << " #{@cb_name} cookbook to the community site? (Y/N) "
    if config[:yes] || (ask_question(confirm_share_msg).chomp.upcase == "Y")
      share_new_version
      ui.msg "Version #{@version} of the #{@cb_name} cookbook has been released!"
      ui.msg "Check it out at http://ckbk.it/#{@cb_name}"
    end
  end

  # @TODO: Increment the current version to the next available odd number
  # algo = n + 1 + (n % 2)
  if config[:devodd]
    puts "I'm odd!"
  end

end

#setupObject



59
60
61
62
63
64
65
66
# File 'lib/chef/knife/community_release.rb', line 59

def setup
  self.config = Chef::Config.merge!(config)
  validate_args
  # Set variables for global use
  @cookbook = name_args.first
  @version = Versionomy.parse(name_args.last) if name_args.size > 1
  return @cookbook, @version, config
end