rakelib/apache.rake in vic-buildr-1.3.1 vs rakelib/apache.rake in vic-buildr-1.3.3

- old
+ new

@@ -12,54 +12,66 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. -require 'md5' -require 'sha1' +require 'digest/md5' +require 'digest/sha1' # Tasks specific to Apache projects (license, release, etc). namespace 'apache' do + desc 'Upload snapshot packages over to people.apache.org' + task 'snapshot'=>['spec', 'package'] do + rm_rf 'snapshot' # Always start with empty directory + puts "Copying existing gems from Apache" + sh 'rsync', '--progress', '--recursive', 'people.apache.org:public_html/buildr/snapshot', './' + puts "Copying new gems over" + cp FileList['pkg/{*.gem,*.tgz,*.zip}'], 'snapshot/gems' + puts "Generating gem index ..." + sh 'gem', 'generate_index', '--directory', 'snapshot' + puts "Copying gem and index back to Apache" + sh 'rsync', '--progress', '--recursive', 'snapshot', 'people.apache.org:public_html/buildr/' + end + + desc 'Check that source files contain the Apache license' task 'license' do |task| print 'Checking that files contain the Apache license ... ' required = task.prerequisites.select { |fn| File.file?(fn) } missing = required.reject { |fn| - comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|<!--(.*?)-->/m). + comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|^-#\s+(.*?)$|<!--(.*?)-->/m). map { |match| match.compact }.flatten.join("\n") comments =~ /Licensed to the Apache Software Foundation/ && comments =~ /http:\/\/www.apache.org\/licenses\/LICENSE-2.0/ } fail "#{missing.join(', ')} missing Apache License, please add it before making a release!" unless missing.empty? puts 'OK' end - task('license').prerequisites.exclude('.class', '.png', '.jar', '.tif', '.textile', '.haml', - 'README', 'LICENSE', 'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'KEYS', 'spec/spec.opts') + + # Staging checks specific for Apache. + task 'check'=>'license' - task 'check' do - ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment variable so we know which key to use.' - end - file 'staged/distro'=>'package' do puts 'Copying and signing release files ...' mkpath 'staged/distro' FileList['pkg/*.{gem,zip,tgz}'].each do |pkg| cp pkg, pkg.pathmap('staged/distro/%n-incubating%x') end end - task 'sign'=>['KEYS', 'staged/distro'] do - gpg_user = ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment variable so we know which key to use.' + task 'sign'=>['etc/KEYS', 'staged/distro'] do |task, args| + gpg_user = args.gpg_user or fail "Please run with gpg_user=<argument for gpg --local-user>" + puts "Signing packages in staged/distro as user #{gpg_user}" FileList['staged/distro/*.{gem,zip,tgz}'].each do |pkg| bytes = File.open(pkg, 'rb') { |file| file.read } File.open(pkg + '.md5', 'w') { |file| file.write MD5.hexdigest(bytes) << ' ' << File.basename(pkg) } File.open(pkg + '.sha1', 'w') { |file| file.write SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) } sh 'gpg', '--local-user', gpg_user, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true end - cp 'KEYS', 'staged/distro' + cp 'etc/KEYS', 'staged/distro' end # Publish prerequisites to distro server. task 'publish:distro' do |task, args| target = args.incubating ? "people.apache.org:/www/www.apache.org/dist/incubator/#{spec.name}/#{spec.version}-incubating" : @@ -94,38 +106,10 @@ file.write modified end puts 'Done' end -=begin - task 'distro-links'=>['staged/site', 'apache:sign'] do |task, args| - rows = FileList['staged/distro/*.{gem,tgz,zip}'].map { |pkg| - name, md5 = File.basename(pkg), File.read("#{pkg}.md5").split.first - <<-HTML - <tr> - <td><a href="#{url}/#{name}">#{name}</a></td> - <td><a href="#{url}/#{name}.md5">#{md5}</a></td> - <td><a href="#{url}/#{name}.asc">Sig</a></td> - </tr> - HTML - } - html = <<-HTML - <h3>#{spec.name} #{spec.version}#{args.incubating && "-incubating"} (#{Time.now.strftime('%Y-%m-%d')})</h3> - <table> - <thead><th>Package</th><th>MD5 Checksum</th><th>PGP</th></thead> - #{rows.join("\n")} - </table> - <p style="text-align:right"> (<a href="#{url}/KEYS">Release signing keys</a>)</p> - HTML - file_name = 'staged/site/download.html' - modified = File.read(file_name).sub(/<h2.*binaries.*source.*<\/h2>.*/i) { |header| "#{header}\n#{html}\n" } - File.open file_name, 'w' do |file| - file.write modified - end - end -=end - file 'staged/site'=>['distro-links', 'staged', 'site'] do rm_rf 'staged/site' cp_r 'site', 'staged' end @@ -139,13 +123,19 @@ end end -task 'stage:check'=>['apache:license', 'apache:check'] +task 'stage:check'=>['apache:check'] task 'stage:prepare'=>['staged/distro', 'staged/site'] do |task| # Since this requires input (passphrase), do it at the very end. task.enhance do task('apache:sign').invoke end end +task 'stage' do + task('apache:snapshot').invoke +end task 'release:publish'=>['apache:publish:distro', 'apache:publish:site'] +task 'clobber' do + rm_rf 'snapshot' +end \ No newline at end of file