groundskeeper-bitcore 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a59a195b265d2acb9f80f92047a932b9d383774
4
- data.tar.gz: cc30dafde4d041ded80022417a6aab76f91505c2
3
+ metadata.gz: 7f39db6a62ffa5c33f67c1ecf6dc92f4cbc569ca
4
+ data.tar.gz: 60fb0063ea4a57a26f778c80487667604d1f16a8
5
5
  SHA512:
6
- metadata.gz: 4a6e194b5cb47ff597fe0088a77b2d9767f949bc748c51813a65a01e4e6460c54b6c62526e02eac519ff2f8d9693a390fe5620d2e80272366169cfcbd4ff35d3
7
- data.tar.gz: 0be07658c32a457a974e6b7809b5e8c021e00acf632d3b33f032513d0c3d1a69e1e3a04c0ec9865a73a6b5ca4adf1202dcb08e8b0b34948b78086f1604e81cf0
6
+ metadata.gz: 0e3d6d56eb88e3fc073452b83bfa44e55adf8c43ee56daed504981688891a42c97cc00083c6d9faee0550fbb7a78a0cfa8786cfad32e1820a8e8486006d1c00b
7
+ data.tar.gz: bf678903fe9d73707c71d92e5c7caa65f7ccea054d35008c0fdd8ef9365a04b7c3abb05521b9a8388bec54e3cd86e914486deaaffc362eb29f48758d6300d40b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1 - 2018-01-03
4
+
5
+ * check latest release version of Groundskeeper before running (#51)
6
+
3
7
  ## 0.2.0 - 2017-11-29
4
8
 
5
9
  * IN-8 Fixes #47 transition Jira issues upon deployment (#48)
data/lib/groundskeeper.rb CHANGED
@@ -10,6 +10,8 @@ require "groundskeeper/jira"
10
10
  require "groundskeeper/project"
11
11
  require "groundskeeper/rails_version"
12
12
  require "groundskeeper/repository"
13
+ require "groundskeeper/rubygems"
14
+ require "groundskeeper/semantic_version"
13
15
  require "groundskeeper/version"
14
16
  require "groundskeeper/website"
15
17
 
@@ -33,14 +33,15 @@ module Groundskeeper
33
33
  git: Git.build,
34
34
  git_hub: git_hub,
35
35
  jira: Jira.build(project.jira_prefix),
36
- repository: repository,
37
36
  project: project,
37
+ repository: repository,
38
+ rubygems: Rubygems,
38
39
  version_file: RailsVersion.new
39
40
  )
40
41
  end
41
42
  # rubocop:enable Metrics/MethodLength
42
43
 
43
- # rubocop:disable Metrics/ParameterLists
44
+ # rubocop:disable Metrics/MethodLength,Metrics/ParameterLists
44
45
  def initialize(
45
46
  changelog: nil,
46
47
  console:,
@@ -49,6 +50,7 @@ module Groundskeeper
49
50
  jira: nil,
50
51
  project: nil,
51
52
  repository: nil,
53
+ rubygems: nil,
52
54
  version_file:
53
55
  )
54
56
  @changelog = changelog
@@ -58,17 +60,19 @@ module Groundskeeper
58
60
  @jira = jira
59
61
  @project = project
60
62
  @repository = repository
63
+ @rubygems = rubygems
61
64
  @version_file = version_file
62
65
  @did_checkout_branch = false
63
66
  @did_push_to_remote = false
64
67
  end
65
- # rubocop:enable Metrics/ParameterLists
68
+ # rubocop:enable Metrics/MethodLength,Metrics/ParameterLists
66
69
 
67
70
  # rubocop:disable Metrics/MethodLength
68
71
  def info
69
72
  return unrecognized_version unless version_file.exists?
70
73
 
71
- announce_version
74
+ return unless check_groundskeeper_version
75
+
72
76
  announce_latest_tag
73
77
  console.say(
74
78
  "version in current branch: " +
@@ -85,6 +89,7 @@ module Groundskeeper
85
89
  def release
86
90
  return unrecognized_version unless version_file.exists?
87
91
  return missing_jira_credentials unless jira.credentials?
92
+ return unless check_groundskeeper_version
88
93
 
89
94
  summarize_recent_commits
90
95
  ask_next_version
@@ -102,21 +107,26 @@ module Groundskeeper
102
107
 
103
108
  def predeploy(options)
104
109
  return unrecognized_version unless version_file.exists?
110
+ return unless check_groundskeeper_version
105
111
 
106
112
  mina "predeploy", options
107
113
  end
108
114
 
109
115
  def deploy(options)
110
116
  return unrecognized_version unless version_file.exists?
117
+ return missing_jira_credentials unless jira.credentials?
118
+ return unless check_groundskeeper_version
111
119
 
112
120
  mina "deploy", options
121
+ console.say("waiting for deployed application to restart...", :yellow)
122
+ update_deployed_issues
113
123
  end
114
124
 
115
125
  private
116
126
 
117
127
  # collaborators
118
128
  attr_reader :changelog, :console, :git, :git_hub, :jira, :project,
119
- :repository, :version_file
129
+ :repository, :rubygems, :version_file
120
130
  # state
121
131
  attr_reader :next_version, :recent_commits, :did_checkout_branch,
122
132
  :did_push_to_remote
@@ -126,12 +136,22 @@ module Groundskeeper
126
136
  cmd << " -s" if options[:simulate]
127
137
  cmd << " -v" if options[:verbose]
128
138
  run_mina cmd
129
- console.say("waiting for deployed application to restart...", :yellow)
130
- update_deployed_issues
131
139
  end
132
140
 
133
- def announce_version
141
+ def check_groundskeeper_version
134
142
  console.say("Groundskeeper version #{Groundskeeper::VERSION}\n\n", :bold)
143
+ latest_version = rubygems.latest_groundskeeper_version
144
+
145
+ if SemanticVersion.new(latest_version) > SemanticVersion.new(VERSION)
146
+ console.say(
147
+ "Groundskeeper is outdated, please install #{latest_version}",
148
+ :red
149
+ )
150
+
151
+ return false
152
+ end
153
+
154
+ true
135
155
  end
136
156
 
137
157
  def announce_latest_tag
@@ -3,10 +3,6 @@
3
3
  module Groundskeeper
4
4
  # A Git repository.
5
5
  class Repository
6
- MAJOR = "major"
7
- MINOR = "minor"
8
- PATCH = "patch"
9
- SEMANTIC_RELEASE_TYPE = { M: MAJOR, m: MINOR, p: PATCH }.freeze
10
6
  # git output matching
11
7
  ON_BRANCH_MASTER = "On branch master"
12
8
  UP_TO_DATE = "Your branch is up-to-date with 'origin/master'"
@@ -52,23 +48,9 @@ module Groundskeeper
52
48
  .reject { |c| c.match(/#{format(RELEASE_MESSAGE, "")}/) }
53
49
  end
54
50
 
55
- # rubocop:disable Metrics/MethodLength
56
51
  def bumped_semantic_version(type)
57
- major, minor, patch = git
58
- .latest_tag_name_across_branches
59
- .split(".")
60
- .map(&:to_i)
61
-
62
- case SEMANTIC_RELEASE_TYPE[type.to_sym]
63
- when MAJOR
64
- "#{major + 1}.0.0"
65
- when MINOR
66
- "#{major}.#{minor + 1}.0"
67
- when PATCH
68
- "#{major}.#{minor}.#{patch + 1}"
69
- end
52
+ SemanticVersion.new(git.latest_tag_name_across_branches).bump(type)
70
53
  end
71
- # rubocop:enable Metrics/MethodLength
72
54
 
73
55
  def name
74
56
  `pwd`.split("/").last.chop
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Groundskeeper
6
+ # Proxy for the Rubygems API.
7
+ class Rubygems
8
+ VERSION_API = "https://rubygems.org/api/v1/versions/"
9
+
10
+ def self.latest_groundskeeper_version
11
+ out = `curl #{VERSION_API}groundskeeper-bitcore/latest.json 2>/dev/null`
12
+ response = JSON.parse(out)
13
+
14
+ response["version"]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Groundskeeper
4
+ # Encapsulates semantic version manipulation and comparison.
5
+ class SemanticVersion
6
+ MAJOR = "major"
7
+ MINOR = "minor"
8
+ PATCH = "patch"
9
+ SEMANTIC_RELEASE_TYPE = { M: MAJOR, m: MINOR, p: PATCH }.freeze
10
+
11
+ attr_reader :major, :minor, :patch
12
+
13
+ def self.build(version)
14
+ return version if version.is_a?(SemanticVersion)
15
+
16
+ new(version)
17
+ end
18
+
19
+ def initialize(version)
20
+ @major, @minor, @patch = version.split(".").map(&:to_i)
21
+ end
22
+
23
+ def bump(release_type)
24
+ case SEMANTIC_RELEASE_TYPE[release_type.to_sym]
25
+ when MAJOR
26
+ "#{major + 1}.0.0"
27
+ when MINOR
28
+ "#{major}.#{minor + 1}.0"
29
+ when PATCH
30
+ "#{major}.#{minor}.#{patch + 1}"
31
+ end
32
+ end
33
+
34
+ def >(other)
35
+ other_version = SemanticVersion.build(other)
36
+ other_major = other_version.major
37
+
38
+ return true if major > other_major
39
+
40
+ return false unless major == other_major
41
+
42
+ other_minor = other_version.minor
43
+
44
+ return true if minor > other_minor
45
+
46
+ minor == other_minor && patch > other_version.patch
47
+ end
48
+ end
49
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Groundskeeper
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groundskeeper-bitcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BIT Core
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - certs/ericcf.pem
12
- date: 2017-11-29 00:00:00.000000000 Z
12
+ date: 2018-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jira-ruby
@@ -151,6 +151,8 @@ files:
151
151
  - lib/groundskeeper/project.rb
152
152
  - lib/groundskeeper/rails_version.rb
153
153
  - lib/groundskeeper/repository.rb
154
+ - lib/groundskeeper/rubygems.rb
155
+ - lib/groundskeeper/semantic_version.rb
154
156
  - lib/groundskeeper/version.rb
155
157
  - lib/groundskeeper/website.rb
156
158
  - servers.yml