rake-release 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5d71af4dc22e9d24faa21d2c014075e491f9b704
4
- data.tar.gz: b74cab41e7cba25aea3ef6a1a04d2a42dd79d66e
2
+ SHA256:
3
+ metadata.gz: 4f57c7ab816f8b5967fada02b402586a25a1a73ffb6fd0cd864133b56ad8afe6
4
+ data.tar.gz: 1e8d380cdb33c8bb029f5be948aef86d41798638919641ec7f3272b005dbf4a9
5
5
  SHA512:
6
- metadata.gz: dc2b0a6c8f89dbb0a04d61da0f261e8d0e2b4745b127c6536e38b46ced6534edf5c0782c2933e7eb1a6f7191406b44b4382e1ac9ce91437936e01e87ad958a90
7
- data.tar.gz: 5f423e6a51c53cf189550aeaa7918f68dfdddba4a172d3db201b4e84428c171099aec131f31782db84d76ed29ea0b16af512ec0517f4f87983768082c1226c61
6
+ metadata.gz: 9c04699feb9d665b3e8449b35be5ae126f70dc88cbfa8a87fba593fcef8adc33b19b24eda1f2b66faa68cd7a698f2916b5aa5ebabbae7b6f89454afe7bb76552
7
+ data.tar.gz: 2803b6c8d933d1c366ff0c66aa3b635841066a66b1cd3717bc0d37d6790ecfb80d9d57fc097625b980c99d1585871a957c919b556ded46d5e2696c2f689ac417
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rake-release.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake'
data/README.md CHANGED
@@ -36,6 +36,72 @@ rake release[remote]
36
36
  Create and push tag v0.2.1, build gem and publish to rubygems.org.
37
37
  ```
38
38
 
39
+ ### With multiple gemspecs
40
+
41
+ ```
42
+ > rake -T
43
+ rake lib-alpha:build # Build lib-alpha-0.6.0.gem.gem into the pkg directory
44
+ rake lib-alpha:install # Build and install lib-alpha-0.6.0.gem into system gems
45
+ rake lib-alpha:install:local # Build and install lib-alpha-0.6.0.gem into system gems without network access
46
+ rake lib-alpha:release[remote] # Create and push tag v0.6.0, build gem and publish to rubygems.org
47
+ rake lib-beta:build # Build lib-beta-0.8.0.gem.gem into the pkg directory
48
+ rake lib-beta:install # Build and install lib-beta-0.8.0.gem into system gems
49
+ rake lib-beta:install:local # Build and install lib-beta-0.8.0.gem into system gems without network access
50
+ rake lib-beta:release[remote] # Create and push tag v0.6.0, build gem and publish to rubygems.org
51
+ ```
52
+
53
+ ### With tag signing
54
+
55
+ Enable tag signing by manually loading the task:
56
+
57
+ ```ruby
58
+ require 'rake/release/task'
59
+
60
+ Rake::Release::Task.new do |spec|
61
+ spec.sign_tag = true
62
+ end
63
+ ```
64
+
65
+ Or with multiple gems:
66
+
67
+ ```ruby
68
+ require 'rake/release/task'
69
+
70
+ Rake::Release::Task.load_all do |spec|
71
+ spec.sign_tag = true
72
+ end
73
+ ```
74
+
75
+ ### Manually set namespace
76
+
77
+ ```ruby
78
+ require 'rake/release/task'
79
+
80
+ Rake::Release::Task.new do |spec|
81
+ spec.namespace = 'client'
82
+ end
83
+ ```
84
+
85
+ ```
86
+ > rake -T
87
+ rake client:build # Build rake-release-0.6.0.gem.gem into the pkg directory
88
+ rake client:install # Build and install rake-release-0.6.0.gem into system gems
89
+ rake client:install:local # Build and install rake-release-0.6.0.gem into system gems without network access
90
+ rake client:release[remote] # Create and push tag v0.6.0, build gem and publish to rubygems.org
91
+ ```
92
+
93
+ ### Set gem host and version tag
94
+
95
+ You can customize the task e.g. with a custom git tag or gem push host:
96
+
97
+ ```ruby
98
+ Rake::Release::Task.load_all do |spec|
99
+ spec.version_tag = "gem-v#{spec.version}"
100
+ spec.host = 'https://user:pass@gemhost/'
101
+ end
102
+
103
+ ```
104
+
39
105
  # License
40
106
 
41
107
  MIT
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
- require 'rake/release'
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'rake/release/task'
5
+
6
+ Rake::Release::Task.new do |spec|
7
+ spec.sign_tag = true
8
+ end
@@ -15,10 +15,11 @@ module Rake
15
15
  attr_reader :gemspec
16
16
  attr_reader :gemspec_path
17
17
 
18
+ attr_accessor :push_host
19
+ attr_accessor :sign_tag
18
20
  attr_accessor :namespace
19
- attr_accessor :version_tag
20
21
 
21
- def initialize(path, namespace: nil)
22
+ def initialize(path = nil, namespace: nil, sign_tag: false)
22
23
  path = Task.pwd.join(path.to_s).expand_path
23
24
 
24
25
  if path.directory?
@@ -36,21 +37,18 @@ module Rake
36
37
 
37
38
  @gemspec = Bundler.load_gemspec @gemspec_path
38
39
 
39
- raise RuntimeError.new 'Cannot load gemspec' unless @gemspec
40
+ raise 'Cannot load gemspec' unless @gemspec
40
41
 
41
- if @gemspec.metadata.fetch('allowed_push_host', nil)
42
- @allowed_push_host = URI @gemspec.metadata['allowed_push_host']
42
+ @push_host = URI 'https://rubygems.org'
43
+
44
+ unless @gemspec.metadata['allowed_push_host'].to_s.empty?
45
+ @push_host = URI @gemspec.metadata['allowed_push_host']
43
46
  end
44
47
 
45
- @version_tag = true
46
- end
48
+ @sign_tag = sign_tag
49
+ @namespace = namespace
47
50
 
48
- def push_host
49
- if @allowed_push_host
50
- @allowed_push_host
51
- else
52
- @push_host ||= URI 'https://rubygems.org'
53
- end
51
+ yield self if block_given?
54
52
  end
55
53
 
56
54
  def push_host=(value)
@@ -76,18 +74,8 @@ module Rake
76
74
  @pkg_file_path ||= pkg_path.join pkg_file_name
77
75
  end
78
76
 
79
- def version_tag?
80
- @version_tag ? true : false
81
- end
82
-
83
77
  def version_tag
84
- if @version_tag.respond_to? :call
85
- @version_tag.call(self).to_s
86
- elsif @version_tag.respond_to? :to_str
87
- @version_tag.to_str
88
- else
89
- "v#{version}"
90
- end
78
+ "v#{version}"
91
79
  end
92
80
 
93
81
  class << self
@@ -100,7 +88,7 @@ module Rake
100
88
  def scan(path = Task.pwd.join('*.gemspec'))
101
89
  Pathname
102
90
  .glob(path)
103
- .map { |path| Rake::Release::Spec.load path }
91
+ .map { |m| Rake::Release::Spec.load(m) }
104
92
  .reject(&:nil?)
105
93
  end
106
94
  end
@@ -13,12 +13,10 @@ module Rake
13
13
  include Rake::DSL
14
14
 
15
15
  def initialize(spec = nil, **kwargs, &block)
16
- @spec = spec || Rake::Release::Spec.new(**kwargs, &block)
16
+ @spec = spec || Rake::Release::Spec.new(spec, **kwargs, &block)
17
17
 
18
- namespace = kwargs[:namespace] || @spec.namespace
19
-
20
- if namespace
21
- send(:namespace, namespace) { setup }
18
+ if @spec.namespace
19
+ send(:namespace, @spec.namespace) { setup }
22
20
  else
23
21
  setup
24
22
  end
@@ -27,47 +25,38 @@ module Rake
27
25
  protected
28
26
 
29
27
  def setup
30
- desc <<-EOF.strip
31
- Build #{@spec.pkg_file_name}.gem into the pkg directory.
32
- EOF
28
+ desc "Build #{@spec.pkg_file_name}.gem into the pkg directory."
33
29
  task(:build) { build }
34
30
 
35
- desc <<-EOF.strip
36
- Build and install #{@spec.pkg_file_name} into system gems.
37
- EOF
31
+ desc "Build and install #{@spec.pkg_file_name} into system gems."
38
32
  task(install: [:build]) { install }
39
33
 
40
- desc <<-EOF.strip
41
- Build and install #{@spec.pkg_file_name} into system gems without network access.
42
- EOF
34
+ desc "Build and install #{@spec.pkg_file_name} into " \
35
+ 'system gems without network access.'
43
36
  task('install:local' => [:build]) { install local: true }
44
37
 
45
- desc ''.tap { |str|
46
- str << if @spec.version_tag?
47
- "Create and push tag #{@spec.version_tag}, build"
48
- else
49
- 'Build'
50
- end
51
-
52
- str << "and publish to #{@spec.push_host_name}."
53
- }
54
- task :release, [:remote] => %w(build release:push release:publish)
38
+ if @spec.sign_tag
39
+ desc "Create, sign and push tag #{@spec.version_tag}, " \
40
+ "build gem and publish to #{@spec.push_host_name}."
41
+ else
42
+ desc "Create and push tag #{@spec.version_tag}, " \
43
+ "build gem and publish to #{@spec.push_host_name}."
44
+ end
45
+ task :release, [:remote] => %w[build release:push release:publish]
55
46
 
56
47
  task 'release:guard:clean' do
57
48
  guard_clean
58
49
  end
59
50
 
60
51
  task 'release:guard:tag' do
61
- guard_tag if @spec.version_tag?
52
+ guard_tag
62
53
  end
63
54
 
64
- task 'release:push', [:remote] => %w(release:guard:clean) do |_, args|
65
- if @spec.version_tag? && !already_tagged?
66
- tag_version { git_push(args[:remote]) }
67
- end
55
+ task 'release:push', [:remote] => %w[release:guard:clean] do |_, args|
56
+ tag_version { git_push(args[:remote]) } unless already_tagged?
68
57
  end
69
58
 
70
- task 'release:publish' => %w(release:guard:tag) do
59
+ task 'release:publish' => %w[release:guard:tag] do
71
60
  publish if publish?
72
61
  end
73
62
  end
@@ -78,11 +67,12 @@ module Rake
78
67
  end
79
68
 
80
69
  def guard_tag
81
- out, ret = sh! 'git', 'tag', '--points-at', 'HEAD'
70
+ out, = sh! 'git', 'tag', '--points-at', 'HEAD'
82
71
 
83
- unless out.split("\n").include? @spec.version_tag
84
- raise "Tag #{@spec.version_tag} does not point to current HEAD. Cannot release wrong code."
85
- end
72
+ return if out.split("\n").include? @spec.version_tag
73
+
74
+ raise "Tag #{@spec.version_tag} does not point to current HEAD. " \
75
+ 'Cannot release wrong code.'
86
76
  end
87
77
 
88
78
  def build
@@ -91,54 +81,60 @@ module Rake
91
81
  sh! 'gem', 'build', '-V', @spec.gemspec_path
92
82
 
93
83
  @spec.pkg_path.mkpath
94
- FileUtils.mv @spec.pkg_file_name, @spec.pkg_path.join(@spec.pkg_file_name)
84
+ FileUtils.mv @spec.pkg_file_name,
85
+ @spec.pkg_path.join(@spec.pkg_file_name)
95
86
 
96
- Task.ui.confirm "#{@spec.name} #{@spec.version} built to #{@spec.pkg_path}."
87
+ Task.ui.confirm \
88
+ "#{@spec.name} #{@spec.version} built to #{@spec.pkg_path}."
97
89
  end
98
90
 
99
91
  def install(local: false)
100
- cmd = %w(gem install) + [@spec.pkg_file_path]
92
+ cmd = %w[gem install] + [@spec.pkg_file_path]
101
93
  cmd << '--local' if local
102
94
 
103
- sh! *cmd
95
+ sh!(*cmd)
104
96
 
105
97
  Task.ui.confirm "#{@spec.name} (#{@spec.version}) installed."
106
98
  end
107
99
 
108
100
  def publish
109
- cmd = %w(gem push)
110
- cmd << @spec.pkg_file_path
111
- cmd << '--host'
112
- cmd << @spec.push_host
101
+ cmd = %w[gem push]
102
+ cmd << @spec.pkg_file_path << '--host' << @spec.push_host
113
103
 
114
- sh! *cmd
104
+ sh!(*cmd)
115
105
 
116
106
  Task.ui.confirm "Pushed #{@spec.pkg_file_name} to #{@spec.push_host}"
117
107
  end
118
108
 
119
109
  def git_clean
120
- clean? && committed? || raise('There are files that need to be committed first.')
110
+ clean? && committed? ||
111
+ raise('There are files that need to be committed first.')
121
112
  end
122
113
 
123
114
  def clean?
124
- out, ret = sh 'git', 'diff', '--exit-code'
115
+ _, ret = sh 'git', 'diff', '--exit-code'
125
116
 
126
- ret == 0
117
+ ret.zero?
127
118
  end
128
119
 
129
120
  def committed?
130
- out, ret = sh 'git', 'diff-index', '--quiet', '--cached', 'HEAD'
121
+ _, ret = sh 'git', 'diff-index', '--quiet', '--cached', 'HEAD'
131
122
 
132
- ret == 0
123
+ ret.zero?
133
124
  end
134
125
 
135
126
  def tag_version
136
- sh! 'git', 'tag', '-a', '-m', "Version #{@spec.version}", @spec.version_tag
127
+ cmd = %w[git tag --annotate]
128
+ cmd << '--sign' if @spec.sign_tag
129
+ cmd << '--message' << "Version #{@spec.version}"
130
+ cmd << @spec.version_tag
131
+
132
+ sh!(*cmd)
137
133
 
138
134
  Task.ui.confirm "Tagged #{@spec.version_tag}."
139
135
 
140
136
  yield if block_given?
141
- rescue
137
+ rescue StandardError
142
138
  Task.ui.error "Untagging #{@spec.version_tag} due to error."
143
139
 
144
140
  sh! 'git', 'tag', '-d', @spec.version_tag
@@ -147,7 +143,7 @@ module Rake
147
143
  end
148
144
 
149
145
  def already_tagged?
150
- out, ret = sh 'git', 'tag'
146
+ out, = sh 'git', 'tag'
151
147
 
152
148
  return false unless out.split(/\n/).include? @spec.version_tag
153
149
 
@@ -157,18 +153,18 @@ module Rake
157
153
  end
158
154
 
159
155
  def git_push(remote)
160
- cmd = %w(git push --quiet)
156
+ cmd = %w[git push --quiet]
161
157
 
162
158
  cmd << remote unless remote.to_s.empty?
163
159
 
164
- sh! *cmd
165
- sh! *cmd, '--tags'
160
+ sh!(*cmd)
161
+ sh!(*cmd, '--tags')
166
162
 
167
163
  Task.ui.confirm 'Pushed git commits and tags.'
168
164
  end
169
165
 
170
166
  def publish?
171
- ! %w(n no nil false off 0).include?(ENV['gem_push'].to_s.downcase)
167
+ !%w[n no nil false off 0].include?(ENV['gem_push'].to_s.downcase)
172
168
  end
173
169
 
174
170
  def sh!(*cmd, **kwargs, &block)
@@ -177,7 +173,7 @@ module Rake
177
173
  out, ret = sh(*cmd, **kwargs, &block)
178
174
 
179
175
  if ret != 0
180
- raise RuntimeError.new <<-EOS.gsub /^\s*\.?/, ''
176
+ raise <<-EOS.gsub(/^\s*\.?/, '')
181
177
  Running `#{cmd}` failed, exit code: #{ret}
182
178
  .#{out.gsub(/\n/, "\n ")}
183
179
  EOS
@@ -186,7 +182,7 @@ module Rake
186
182
  [out, ret]
187
183
  end
188
184
 
189
- def sh(*cmd, chdir: @spec.base, raise_error: true)
185
+ def sh(*cmd, chdir: @spec.base)
190
186
  cmd = cmd.flatten.map(&:to_s)
191
187
 
192
188
  Task.ui.debug cmd
@@ -204,11 +200,14 @@ module Rake
204
200
  def load_all(dir = pwd)
205
201
  specs = Spec.scan dir.join('**/*.gemspec')
206
202
 
207
- specs.each { |spec| spec.namespace = spec.name } if specs.size > 1
203
+ if specs.size > 1
204
+ specs.each { |spec| spec.namespace = spec.name }
205
+ end
206
+
208
207
  specs.each(&Proc.new) if block_given?
209
208
 
210
209
  if specs.uniq { |s| s.namespace.to_s.strip }.size != specs.size
211
- raise RuntimeError.new 'Non distinct release task namespaces'
210
+ raise 'Non distinct release task namespaces'
212
211
  end
213
212
 
214
213
  specs.each { |spec| Task.new spec }
data/rake-release.gemspec CHANGED
@@ -1,8 +1,6 @@
1
- # coding: utf-8
2
-
3
1
  Gem::Specification.new do |spec|
4
2
  spec.name = 'rake-release'
5
- spec.version = '0.5.0'
3
+ spec.version = '1.0.0'
6
4
  spec.authors = ['Jan Graichen']
7
5
  spec.email = ['jgraichen@altimos.de']
8
6
  spec.licenses = ['MIT']
@@ -13,10 +11,9 @@ Gem::Specification.new do |spec|
13
11
 
14
12
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
13
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
- spec.require_paths = %w(lib)
14
+ spec.require_paths = %w[lib]
17
15
 
18
16
  spec.add_dependency 'bundler', '~> 1.11'
19
17
 
20
18
  spec.add_development_dependency 'bundler', '~> 1.11'
21
- spec.add_development_dependency 'rake', '~> 10.0'
22
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.11'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
41
  description: Configurable fork of bundlers release tasks.
56
42
  email:
57
43
  - jgraichen@altimos.de
@@ -90,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
76
  version: '0'
91
77
  requirements: []
92
78
  rubyforge_project:
93
- rubygems_version: 2.6.4
79
+ rubygems_version: 2.7.3
94
80
  signing_key:
95
81
  specification_version: 4
96
82
  summary: Configurable fork of bundlers release tasks.