Class: Groundskeeper::Commands
- Inherits:
-
Object
- Object
- Groundskeeper::Commands
- 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"- INITIAL_VERSION =
"0.0.1"
Class Method Summary collapse
-
.build(console) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
-
.stage ⇒ Object
rubocop:enable Metrics/AbcSize,Metrics/MethodLength.
Instance Method Summary collapse
-
#deploy(options) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#info ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize.
-
#initialize(changelog: nil, console:, git: nil, git_hub: nil, jira: nil, project: nil, repository: nil, rubygems: nil, sentry: nil, website: nil, version_file:) ⇒ Commands
constructor
rubocop:disable Metrics/MethodLength,Metrics/ParameterLists.
-
#predeploy(options) ⇒ Object
:nocov:.
-
#release ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity.
Constructor Details
#initialize(changelog: nil, console:, git: nil, git_hub: nil, jira: nil, project: nil, repository: nil, rubygems: nil, sentry: nil, website: nil, version_file:) ⇒ Commands
rubocop:disable Metrics/MethodLength,Metrics/ParameterLists
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 |
# File 'lib/groundskeeper/commands.rb', line 58 def initialize( changelog: nil, console:, git: nil, git_hub: nil, jira: nil, project: nil, repository: nil, rubygems: nil, sentry: nil, website: nil, version_file: ) @changelog = changelog @console = console @git = git @git_hub = git_hub @jira = jira @project = project @repository = repository @rubygems = rubygems @sentry = sentry @website = website @version_file = version_file @did_checkout_branch = false @did_push_to_remote = false @current_step = 1 end |
Class Method Details
.build(console) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/groundskeeper/commands.rb', line 23 def self.build(console) repository = Repository.new project = Project.build(repository.name) deploy_url = "https://#{project.full_dns(stage)}" website = Website.new(deploy_url) git_hub = GitHub.build( username: project.source_control_username, repository_name: repository.name ) sentry = Sentry.build( project_name: project.sentry_project, version_prefix: 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, sentry: sentry, version_file: RailsVersion.build, website: website ) end |
.stage ⇒ Object
rubocop:enable Metrics/AbcSize,Metrics/MethodLength
53 54 55 |
# File 'lib/groundskeeper/commands.rb', line 53 def self.stage ENV[STAGE] == PRODUCTION ? PRODUCTION : DEFAULT_STAGE end |
Instance Method Details
#deploy(options) ⇒ Object
rubocop:disable Metrics/AbcSize
142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/groundskeeper/commands.rb', line 142 def deploy() return unrecognized_version unless version_file.exists? return unrecognized_tag unless tag_present_in_git?(ENV[TAG]) return missing_jira_credentials unless jira.credentials? return unless check_groundskeeper_version pull_project_details ENV["whenever"] = "1" if project.uses_whenever? mina "deploy", announce_step "Wait for deployed application to restart" update_deployed_issues add_version_to_sentry end |
#info ⇒ Object
rubocop:disable Metrics/MethodLength,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 info return unrecognized_version unless version_file.exists? return unless check_groundskeeper_version pull_project_details 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
:nocov:
132 133 134 135 136 137 138 |
# File 'lib/groundskeeper/commands.rb', line 132 def predeploy() return unrecognized_version unless version_file.exists? return unless check_groundskeeper_version pull_project_details mina "predeploy", end |
#release ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/groundskeeper/commands.rb', line 108 def release is_initial_release = !version_file.exists? return missing_jira_credentials unless jira.credentials? return unless check_groundskeeper_version return unrecognized_version unless version_file.rails? version_file.create_initial_version! unless version_file.exists? pull_project_details summarize_recent_commits unless is_initial_release ask_next_version(is_initial_release) ask_new_branch update_version_file update_changelog commit_changes_and_tag(is_initial_release) ask_create_jira_version ask_add_version_to_jira_issues unless is_initial_release open_pull_request_page end |