0
desc 'Check that source files contain the Apache license'
0
+ task 'license' do
|task|0
print 'Checking that files contain the Apache license ... '
0
- excluded = ['.class', '.png', '.jar', '.tif', 'README', 'LICENSE', 'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'KEYS']
0
- required = FileList[spec.files].exclude(*excluded).exclude(*Array($license_excluded)).select { |fn| File.file?(fn) }
0
+ required = task.prerequisites.select { |fn| File.file?(fn) }
0
missing = required.reject { |fn|
0
comments = File.read(fn).scan(/(\/\*(.*?)\*\/)|^#\s+(.*?)$|<!--(.*?)-->/m).
0
map { |match| match.compact }.flatten.join("\n")
0
fail "#{missing.join(', ')} missing Apache License, please add it before making a release!" unless missing.empty?
0
+ task('license').prerequisites.exclude('.class', '.png', '.jar', '.tif', '.textile', '.haml',
0
+ 'README', 'LICENSE', 'CHANGELOG', 'DISCLAIMER', 'NOTICE', 'KEYS', 'spec/spec.opts')
0
- file 'incubating'=>'package' do
0
- print 'Creating -incubating packages ... '
0
- packages = FileList['pkg/*.{gem,zip,tgz}'].map do |package|
0
- package.pathmap('incubating/%n-incubating%x').tap do |incubating|
0
- cp package, incubating
0
+ ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment variable so we know which key to use.'
0
- task 'sign', :incubating do |task, args|
0
- file('incubating').invoke if args.incubating
0
- sources = FileList[args.incubating ? 'incubating/*' : 'pkg/*']
0
+ file 'staged/distro'=>'package' do
0
+ puts 'Copying and signing release files ...'
0
+ mkpath 'staged/distro'
0
+ FileList['pkg/*.{gem,zip,tgz}'].each do |pkg|
0
+ cp pkg, pkg.pathmap('staged/distro/%n-incubating%x')
0
+ task 'sign'=>['KEYS', 'staged/distro'] do
0
gpg_user = ENV['GPG_USER'] or fail 'Please set GPG_USER (--local-user) environment variable so we know which key to use.'
0
- print 'Signing release files ...'
0
- contents = File.open(fn, 'rb') { |file| file.read }
0
- File.open(fn + '.md5', 'w') { |file| file.write MD5.hexdigest(contents) << ' ' << File.basename(fn) }
0
- File.open(fn + '.sha1', 'w') { |file| file.write SHA1.hexdigest(contents) << ' ' << File.basename(fn) }
0
- sh 'gpg', '--local-user', gpg_user, '--armor', '--output', fn + '.asc', '--detach-sig', fn, :verbose=>true
0
+ FileList['staged/distro/*.{gem,zip,tgz}'].each do |pkg|
0
+ bytes = File.open(pkg, 'rb') { |file| file.read }
0
+ File.open(pkg + '.md5', 'w') { |file| file.write MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
0
+ File.open(pkg + '.sha1', 'w') { |file| file.write SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
0
+ sh 'gpg', '--local-user', gpg_user, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
0
+ cp 'KEYS', 'staged/distro'
0
+ # Publish prerequisites to distro server.
0
+ task 'publish:distro' do |task, args|
0
+ target = args.incubating ? "people.apache.org:/www/www.apache.org/dist/incubator/#{spec.name}" :
0
+ "people.apache.org:/www/www.apache.org/dist/#{spec.name}"
0
+ "people.apache.org:/www/#{spec.name}.apache.org"
0
+ puts 'Uploading packages to Apache distro ...'
0
+ sh 'rsync', '--progress', 'published/distro/*', target
0
- task 'upload', :project, :incubating, :depends=>['site', 'KEYS', 'sign'] do |task, args|
0
- fail 'No project specified' unless project
0
- target = 'people.apache.org:/www.apache.org/dist/'
0
- target << 'incubator/' if args.incubating
0
- target << "#{project}/"
0
+ file 'staged/site'=>'site' do
0
- dir = task('sign').prerequisite.find { |prereq| File.directory?(prereq.name) }
0
- fail 'Please enhance sign task with directory containing files to release' unless dir
0
- puts 'Uploading packages to Apache dist ...'
0
- args = FileList["#{dir}/*", 'KEYS'].flatten << target
0
- sh 'rsync', '-progress', *args
0
+ # Publish prerequisites to Web site.
0
+ task 'publish:site' do |task, args|
0
+ target = args.incubating ? "people.apache.org:/www/incubator.apache.org/#{spec.name}" :
0
+ "people.apache.org:/www/#{spec.name}.apache.org"
0
+ puts 'Uploading Apache Web site ...'
0
+ sh 'rsync', '--progress', 'published/distro/site/', target
0
- task 'check'=>'apache:license'
0
+task 'stage:check'=>['apache:license', 'apache:check']
0
+task 'stage:prepare'=>['staged/distro', 'apache:sign', 'staged/site']
0
+task 'release:publish'=>['apache:publish:distro', 'apache:publish:site']