2929
3030require 'rake_compiler_dock'
3131namespace :repackage do
32- desc '- with Windows fat distributions'
32+ desc '* with Windows fat distributions'
3333 task :all do
3434 Dir . chdir ( __dir__ ) do
3535 sh 'bundle package'
36+ # needed only if the jar is built outside of docker
37+ Rake ::Task [ 'lib/concurrent/concurrent_ruby.jar' ] . invoke
3638 RakeCompilerDock . exec 'support/cross_building.sh'
3739 end
3840 end
@@ -60,19 +62,19 @@ begin
6062 --tag ~notravis ]
6163
6264 namespace :spec do
63- desc '- Configured for ci'
65+ desc '* Configured for ci'
6466 RSpec ::Core ::RakeTask . new ( :ci ) do |t |
6567 t . rspec_opts = [ *options ] . join ( ' ' )
6668 end
6769
68- desc '- test packaged and installed gems instead of local files'
69- task :installed => :repackage do
70+ desc '* test packaged and installed gems instead of local files'
71+ task :installed do
7072 Dir . chdir ( __dir__ ) do
7173 sh 'gem install pkg/concurrent-ruby-1.1.0.pre1.gem'
7274 sh 'gem install pkg/concurrent-ruby-ext-1.1.0.pre1.gem' if Concurrent . on_cruby?
7375 sh 'gem install pkg/concurrent-ruby-edge-0.4.0.pre1.gem'
7476 ENV [ 'NO_PATH' ] = 'true'
75- sh 'bundle install '
77+ sh 'bundle update '
7678 sh 'bundle exec rake spec:ci'
7779 end
7880 end
@@ -86,6 +88,8 @@ rescue LoadError => e
8688 puts 'RSpec is not installed, skipping test task definitions: ' + e . message
8789end
8890
91+ current_yard_version_name = Concurrent ::VERSION . split ( '.' ) [ 0 ..2 ] . join ( '.' )
92+
8993begin
9094 require 'yard'
9195 require 'md_ruby_eval'
@@ -99,79 +103,122 @@ begin
99103 '--title' , 'Concurrent Ruby' ,
100104 '--template' , 'default' ,
101105 '--template-path' , 'yard-template' ,
102- '--default-return' , 'undocumented' , ]
106+ '--default-return' , 'undocumented' ]
103107
104108 desc 'Generate YARD Documentation (signpost, master)'
105109 task :yard => [ 'yard:signpost' , 'yard:master' ]
106110
107111 namespace :yard do
108112
109- desc '- eval markdown files'
113+ desc '* eval markdown files'
110114 task :eval_md do
111115 Dir . chdir File . join ( __dir__ , 'docs-source' ) do
112116 sh 'bundle exec md-ruby-eval --auto'
113117 end
114118 end
115119
120+ task :update_readme do
121+ Dir . chdir __dir__ do
122+ content = File . read ( File . join ( 'README.md' ) ) .
123+ gsub ( /\[ ([\w ]+)\] \( http:\/ \/ ruby-concurrency\. github\. io\/ concurrent-ruby\/ master\/ .*\) / ) do |_ |
124+ case $1
125+ when 'LockFreeLinkedSet'
126+ "{Concurrent::Edge::#{ $1} #{ $1} }"
127+ when '.dataflow'
128+ '{Concurrent.dataflow Concurrent.dataflow}'
129+ when 'thread pool'
130+ '{file:thread_pools.md thread pool}'
131+ else
132+ "{Concurrent::#{ $1} #{ $1} }"
133+ end
134+ end
135+ File . write 'tmp/README.md' , content
136+ end
137+ end
138+
116139 define_yard_task = -> name do
117- desc "- of #{ name } into subdir #{ name } "
140+ desc "* of #{ name } into subdir #{ name } "
118141 YARD ::Rake ::YardocTask . new ( name ) do |yard |
119142 yard . options . push (
120143 '--output-dir' , "docs/#{ name } " ,
144+ '--main' , 'tmp/README.md' ,
121145 *common_yard_options )
122146 yard . files = [ './lib/**/*.rb' ,
123147 './lib-edge/**/*.rb' ,
124148 './ext/concurrent_ruby_ext/**/*.c' ,
125149 '-' ,
126150 'docs-source/thread_pools.md' ,
127151 'docs-source/promises.out.md' ,
128- 'README.md' ,
129- 'LICENSE.txt' ,
152+ 'LICENSE.md' ,
130153 'CHANGELOG.md' ]
131154 end
132- Rake ::Task [ name ] . prerequisites . push 'yard:eval_md'
155+ Rake ::Task [ name ] . prerequisites . push 'yard:eval_md' , 'yard:update_readme'
133156 end
134157
135- define_yard_task . call ( Concurrent :: VERSION . split ( '.' ) [ 0 .. 2 ] . join ( '.' ) )
136- define_yard_task . call ( 'master' )
158+ define_yard_task . call current_yard_version_name
159+ define_yard_task . call 'master'
137160
138- desc "- signpost for versions"
161+ desc "* signpost for versions"
139162 YARD ::Rake ::YardocTask . new ( :signpost ) do |yard |
140163 yard . options . push (
141164 '--output-dir' , 'docs' ,
142165 '--main' , 'docs-source/signpost.md' ,
143166 *common_yard_options )
144167 yard . files = [ 'no-lib' ]
145168 end
146- end
147169
148- namespace :spec do
149- desc '- ensure that generated documentation is matching the source code'
150- task :docs_uptodate do
151- Dir . chdir ( __dir__ ) do
152- begin
153- FileUtils . cp_r 'docs' , 'docs-copy' , verbose : true
154- Rake ::Task [ :yard ] . invoke
155- sh 'diff -r docs/ docs-copy/'
156- ensure
157- FileUtils . rm_rf 'docs-copy' , verbose : true
170+ define_uptodate_task = -> name do
171+ namespace name do
172+ desc "** ensure that #{ name } generated documentation is matching the source code"
173+ task :uptodate do
174+ Dir . chdir ( __dir__ ) do
175+ begin
176+ FileUtils . cp_r 'docs' , 'docs-copy' , verbose : true
177+ Rake ::Task [ "yard:#{ name } " ] . invoke
178+ sh 'diff -r docs/ docs-copy/'
179+ ensure
180+ FileUtils . rm_rf 'docs-copy' , verbose : true
181+ end
182+ end
158183 end
159184 end
160185 end
186+
187+ define_uptodate_task . call current_yard_version_name
188+ define_uptodate_task . call 'master'
161189 end
162190
163191rescue LoadError => e
164192 puts 'YARD is not installed, skipping documentation task definitions: ' + e . message
165193end
166194
195+ desc 'build, test, and publish the gem'
196+ task :release => [ 'release:checks' , 'release:build' , 'release:test' , 'release:publish' ]
197+
167198namespace :release do
168199 # Depends on environment of @pitr-ch
169200
170- mri_version = '2.4.3 '
201+ mri_version = '2.5.1 '
171202 jruby_version = 'jruby-9.1.17.0'
172203
204+ task :checks => "yard:#{ current_yard_version_name } :uptodate" do
205+ Dir . chdir ( __dir__ ) do
206+ begin
207+ STDOUT . puts "Is this a final release build? (Do git checks?) (y/n)"
208+ input = STDIN . gets . strip . downcase
209+ end until %w( y n ) . include? ( input )
210+ if input == 'y'
211+ sh 'test -z "$(git status --porcelain)"'
212+ sh 'git fetch'
213+ sh 'test $(git show-ref --verify --hash refs/heads/master) = $(git show-ref --verify --hash refs/remotes/github/master)'
214+ end
215+ end
216+ end
217+
218+ desc '* build all *.gem files necessary for release'
173219 task :build => 'repackage:all'
174220
221+ desc '* test actual installed gems instead of cloned repository on MRI and JRuby'
175222 task :test do
176223 Dir . chdir ( __dir__ ) do
177224 old = ENV [ 'RBENV_VERSION' ]
@@ -190,27 +237,43 @@ namespace :release do
190237 end
191238 end
192239
193- task :push do
194- Dir . chdir ( __dir__ ) do
195- sh 'git fetch'
196- sh 'test $(git show-ref --verify --hash refs/heads/master) = $(git show-ref --verify --hash refs/remotes/github/master)'
197-
198- sh "git tag v#{ Concurrent ::VERSION } "
199- sh "git tag edge-v#{ Concurrent ::EDGE_VERSION } "
200- sh "git push github v#{ Concurrent ::VERSION } edge-v#{ Concurrent ::EDGE_VERSION } "
201-
202- sh "gem push pkg/concurrent-ruby-#{ Concurrent ::VERSION } .gem"
203- sh "gem push pkg/concurrent-ruby-edge-#{ Concurrent ::EDGE_VERSION } .gem"
204- sh "gem push pkg/concurrent-ruby-ext-#{ Concurrent ::VERSION } .gem"
205- sh "gem push pkg/concurrent-ruby-ext-#{ Concurrent ::VERSION } -x64-mingw32.gem"
206- sh "gem push pkg/concurrent-ruby-ext-#{ Concurrent ::VERSION } -x86-mingw32.gem"
240+ desc '* do all nested steps'
241+ task :publish => [ 'publish:ask' , 'publish:tag' , 'publish:rubygems' , 'publish:post_steps' ]
242+
243+ namespace :publish do
244+ task :ask do
245+ begin
246+ STDOUT . puts "Do you want to publish? (y/n)"
247+ input = STDIN . gets . strip . downcase
248+ end until %w( y n ) . include? ( input )
249+ raise 'reconsidered' if input == 'n'
207250 end
208- end
209251
210- task :notify do
211- puts 'Manually: create a release on GitHub with relevant changelog part'
212- puts 'Manually: send email same as release with relevant changelog part'
213- puts 'Manually: update documentation'
214- puts ' $ bundle exec rake yard:push'
252+ desc '** tag HEAD with current version and push to github'
253+ task :tag do
254+ Dir . chdir ( __dir__ ) do
255+ sh "git tag v#{ Concurrent ::VERSION } "
256+ sh "git tag edge-v#{ Concurrent ::EDGE_VERSION } "
257+ sh "git push github v#{ Concurrent ::VERSION } edge-v#{ Concurrent ::EDGE_VERSION } "
258+ end
259+ end
260+
261+ desc '** push all *.gem files to rubygems'
262+ task :rubygems do
263+ Dir . chdir ( __dir__ ) do
264+ sh "gem push pkg/concurrent-ruby-#{ Concurrent ::VERSION } .gem"
265+ sh "gem push pkg/concurrent-ruby-edge-#{ Concurrent ::EDGE_VERSION } .gem"
266+ sh "gem push pkg/concurrent-ruby-ext-#{ Concurrent ::VERSION } .gem"
267+ sh "gem push pkg/concurrent-ruby-ext-#{ Concurrent ::VERSION } -x64-mingw32.gem"
268+ sh "gem push pkg/concurrent-ruby-ext-#{ Concurrent ::VERSION } -x86-mingw32.gem"
269+ end
270+ end
271+
272+ desc '** print post release steps'
273+ task :post_steps do
274+ puts 'Manually: create a release on GitHub with relevant changelog part'
275+ puts 'Manually: send email same as release with relevant changelog part'
276+ puts 'Manually: tweet'
277+ end
215278 end
216279end
0 commit comments