Class: DeployRubygem::Rubygem

Inherits:
Project
  • Object
show all
Defined in:
lib/deploy_rubygem/rubygem.rb

Overview

Using Rubygem to deploy and manage Rubygem

Constant Summary

Constants included from DeployRubygem

VERSION

Instance Attribute Summary

Attributes inherited from Project

#compliance_profile, #cookbooks, #project_options

Instance Method Summary collapse

Methods inherited from Project

#binaries, #change_to_chefrepo, #change_to_directory, #change_to_project_folder, #chefrepo_git, #chefrepo_path, #dependencies, #deploy_cookbooks, #git, #git_commit, #initialize, #path, #project_name, #release_cookbooks, #test_compliance

Methods included from RSpecTesting

#check_current_version, #help_rspec, #install_gem_via_git, #testing_chef, #testing_gem, #testing_inspec, #testing_project, #testing_workstation

Methods included from DeployRubygem

#bootstrap_chef_workstation, #chef_accept_cmd, #chef_env_cmd, deployer, exemple_cookbook, #install_chef_workstation, #no_option_txt, #rubygem_test, #unknown_option_txt

Constructor Details

This class inherits a constructor from DeployRubygem::Project

Instance Method Details

#deployObject



78
79
80
81
82
83
84
85
# File 'lib/deploy_rubygem/rubygem.rb', line 78

def deploy
  change_to_chefrepo
  deploy_cookbooks
  change_to_project_folder

  # release
  test_compliance
end

#deploy_dependenciesObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/deploy_rubygem/rubygem.rb', line 11

def deploy_dependencies
  dependencies.each do |git_depends|
    Dir.chdir(::File.join(Dir.home, git_depends))
    system('git pull')

    system('git add .')

    system("git commit -m \"Deploying #{project_name}_$(git version-bump show)\"")

    system('git push')
  end
end

#deploy_with_gitObject



48
49
50
51
52
53
54
# File 'lib/deploy_rubygem/rubygem.rb', line 48

def deploy_with_git
  deploy_dependencies
  git_sync
  git_prepare

  push_minor_bump
end

#git_prepareObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/deploy_rubygem/rubygem.rb', line 24

def git_prepare
  binaries.each do |executable|
    system("git add bin/#{executable}")
  end

  system('git add deploy_rubygem.gemspec')
  system('git add .circleci/config.yml')

  system('git add lib')
end

#git_syncObject



35
36
37
38
# File 'lib/deploy_rubygem/rubygem.rb', line 35

def git_sync
  Dir.chdir(path)
  system('git pull')
end

#push_minor_bumpObject



40
41
42
43
44
45
46
# File 'lib/deploy_rubygem/rubygem.rb', line 40

def push_minor_bump
  system("git commit -m \"Deploying #{project_name}_$(git version-bump show)\"")
  system('git version-bump patch') # <major|minor|patch|show>
  system('gem build')
  system('gem push deploy_rubygem-$(git version-bump show).gem')
  system('git version-bump minor') # <major|minor|patch|show>
end

#rake_releaseObject



65
66
67
68
69
70
# File 'lib/deploy_rubygem/rubygem.rb', line 65

def rake_release
  change_to_project_folder
  git_commit
  system('rake install') || abort("Cannot rake install #{project_name} #{GVB.version}")
  # system('rake release') || exit(105)
end

#rake_testObject



56
57
58
59
60
61
62
63
# File 'lib/deploy_rubygem/rubygem.rb', line 56

def rake_test
  FileUtils.rm_f('Gemfile.lock')
  system('bundle') || return
  system('bundle install') || return
  system('rake') || return
  # system('rake build') &&
  # system('rake install:local') &&
end

#releaseObject



72
73
74
75
76
# File 'lib/deploy_rubygem/rubygem.rb', line 72

def release
  change_to_project_folder
  rake_test
  rake_release
end