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



55
56
57
58
59
60
61
62
63
64
65
66
67
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
# File 'lib/chef/knife/community_release.rb', line 55

def run
  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

  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
  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

  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