Class: Groundskeeper::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/groundskeeper/commands.rb

Overview

Formulas for managing releases and deployments. rubocop:disable Metrics/ClassLength

Constant Summary collapse

RAKEFILE =
File.join(
  File.dirname(__FILE__), "..", "..", "config", "deploy.rb"
)
STAGE =
"stage"
STAGING =
"staging"
PRODUCTION =
"production"
DEFAULT_STAGE =
STAGING
TAG =
"tag"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changelog: nil, console:, git: nil, git_hub: nil, jira: nil, project: nil, repository: nil, rubygems: nil, version_file:) ⇒ Commands

rubocop:disable Metrics/MethodLength,Metrics/ParameterLists



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/groundskeeper/commands.rb', line 45

def initialize(
  changelog: nil,
  console:,
  git: nil,
  git_hub: nil,
  jira: nil,
  project: nil,
  repository: nil,
  rubygems: nil,
  version_file:
)
  @changelog = changelog
  @console = console
  @git = git
  @git_hub = git_hub
  @jira = jira
  @project = project
  @repository = repository
  @rubygems = rubygems
  @version_file = version_file
  @did_checkout_branch = false
  @did_push_to_remote = false
end

Class Method Details

.build(console) ⇒ Object

rubocop:disable Metrics/MethodLength



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/groundskeeper/commands.rb', line 22

def self.build(console)
  repository = Repository.new
  project = Project.build(repository.name)
  git_hub = GitHub.build(
    username: project.source_control_username,
    repository_name: repository.name
  )

  new(
    changelog: Changelog.build,
    console: console,
    git: Git.build,
    git_hub: git_hub,
    jira: Jira.build(project.jira_prefix),
    project: project,
    repository: repository,
    rubygems: Rubygems,
    version_file: RailsVersion.new
  )
end

Instance Method Details

#deploy(options) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/groundskeeper/commands.rb', line 115

def deploy(options)
  return unrecognized_version unless version_file.exists?
  return missing_jira_credentials unless jira.credentials?
  return unless check_groundskeeper_version

  mina "deploy", options
  console.say("waiting for deployed application to restart...", :yellow)
  update_deployed_issues
end

#info ⇒ Object

rubocop:disable Metrics/MethodLength



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/groundskeeper/commands.rb', line 71

def info
  return unrecognized_version unless version_file.exists?

  return unless check_groundskeeper_version

  announce_latest_tag
  console.say(
    "version in current branch: " +
    version_file.current_version,
    :yellow
  )
  console.say(
    "tag contained in: #{git.branches_containing_latest_tag}\n\n",
    :yellow
  )
end

#predeploy(options) ⇒ Object

rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength



108
109
110
111
112
113
# File 'lib/groundskeeper/commands.rb', line 108

def predeploy(options)
  return unrecognized_version unless version_file.exists?
  return unless check_groundskeeper_version

  mina "predeploy", options
end

#release ⇒ Object

rubocop:disable Metrics/AbcSize



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/groundskeeper/commands.rb', line 89

def release
  return unrecognized_version unless version_file.exists?
  return missing_jira_credentials unless jira.credentials?
  return unless check_groundskeeper_version

  summarize_recent_commits
  ask_next_version
  ask_new_branch
  update_version_file
  update_changelog
  commit_changes_and_tag
  ask_create_jira_version
  ask_push_with_tags
  ask_add_version_to_jira_issues
  open_pull_request_page
end