Rakefile in ruboto-0.13.0.rc.0 vs Rakefile in ruboto-0.13.0
- old
+ new
@@ -1,22 +1,28 @@
$:.unshift('lib') unless $:.include?('lib')
+require 'date'
require 'rake/clean'
require 'rexml/document'
require 'ruboto/version'
require 'ruboto/description'
require 'ruboto/sdk_versions'
require 'uri'
require 'net/https'
+PROJECT_DIR = File.expand_path(File.dirname(__FILE__))
PLATFORM_PROJECT = File.expand_path('tmp/RubotoCore', File.dirname(__FILE__))
PLATFORM_DEBUG_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-debug.apk"
PLATFORM_DEBUG_APK_BAK = "#{PLATFORM_PROJECT}/bin/RubotoCore-debug.apk.bak"
PLATFORM_RELEASE_APK = "#{PLATFORM_PROJECT}/bin/RubotoCore-release.apk"
PLATFORM_CURRENT_RELEASE_APK = File.expand_path('tmp/RubotoCore-release.apk', File.dirname(__FILE__))
MANIFEST_FILE = 'AndroidManifest.xml'
GEM_FILE = "ruboto-#{Ruboto::VERSION}.gem"
GEM_SPEC_FILE = 'ruboto.gemspec'
+README_FILE = 'README.md'
+BLOG_DIR = "#{File.dirname PROJECT_DIR}/ruboto.github.com/_posts"
+RELEASE_BLOG = "#{BLOG_DIR}/#{Date.today}-Ruboto-#{Ruboto::VERSION}-release-doc.md"
+RELEASE_BLOG_GLOB = "#{BLOG_DIR}/*-Ruboto-#{Ruboto::VERSION}-release-doc.md"
CLEAN.include('ruboto-*.gem', 'tmp')
task :default => :gem
@@ -64,12 +70,12 @@
desc 'Generate an example app'
task :example => :install do
require 'ruboto/sdk_locations'
EXAMPLE_FILE = File.expand_path("examples/RubotoTestApp_#{Ruboto::VERSION}_tools_r#{Ruboto::SdkLocations::ANDROID_TOOLS_REVISION}.tgz", File.dirname(__FILE__))
- examples_glob = "#{EXAMPLE_FILE.slice(/^.*?_\d+\.\d+\.\d+/)}*"
- sh "git rm #{examples_glob}" unless Dir[examples_glob].empty?
+ EXAMPLES_GLOB = "#{EXAMPLE_FILE.slice(/^.*?_\d+\.\d+\.\d+/)}*"
+ sh "git rm #{EXAMPLES_GLOB}" unless Dir[EXAMPLES_GLOB].empty?
puts "Creating example app #{EXAMPLE_FILE}"
app_name = 'RubotoTestApp'
Dir.chdir File.dirname(EXAMPLE_FILE) do
FileUtils.rm_rf app_name
sh "ruboto gen app --package org.ruboto.test_app --name #{app_name} --path #{app_name}"
@@ -82,13 +88,18 @@
def wrap(indent = 0)
scan(/\S.{0,72}\S(?=\s|$)|\S+/).join("\n" + ' ' * indent)
end
end
+desc 'Update the README with the Ruboto description.'
+file README_FILE => 'lib/ruboto/description.rb' do
+ File.write(README_FILE, File.read(README_FILE).sub(/(?<=\n\n).*(?=\nInstallation)/m, Ruboto::DESCRIPTION))
+end
+
desc 'Generate release docs for a given milestone'
-task :release_docs do
- raise "\n This task requires Ruby 1.9 or newer to parse JSON as YAML.\n\n" if RUBY_VERSION == '1.8.7'
+
+def get_github_issues
puts 'GitHub login:'
begin
require 'rubygems'
require 'highline/import'
user = ask('login : ') { |q| q.echo = true }
@@ -127,11 +138,15 @@
res = https.start { |http| http.request(req) }
issues = YAML.load(res.body).sort_by { |i| i['number'] }
milestone_name = issues[0] ? issues[0]['milestone']['title'] : "No issues for milestone #{milestone}"
milestone_description = issues[0] ? issues[0]['milestone']['description'] : "No issues for milestone #{milestone}"
milestone_description = milestone_description.split("\r\n").map(&:wrap).join("\r\n")
- categories = {'Features' => 'feature', 'Bugfixes' => 'bug', 'Internal' => 'internal', 'Support' => 'support', 'Documentation' => 'documentation', 'Pull requests' => nil, 'Other' => nil}
+ categories = {
+ 'Features' => 'feature', 'Bugfixes' => 'bug', 'Support' => 'support',
+ 'Documentation' => 'documentation', 'Pull requests' => nil,
+ 'Internal' => 'internal', 'Rejected' => 'rejected', 'Other' => nil
+ }
grouped_issues = issues.group_by do |i|
labels = i['labels'].map { |l| l['name'] }
cat = nil
categories.each do |k, v|
if labels.include? v
@@ -141,14 +156,20 @@
end
cat ||= i['pull_request'] && i['pull_request']['html_url'] && 'Pull requests'
cat ||= 'Other'
cat
end
+ return categories, grouped_issues, milestone, milestone_description, milestone_name
+end
+task :release_docs do
+ raise "\n This task requires Ruby 1.9 or newer to parse JSON as YAML.\n\n" if RUBY_VERSION == '1.8.7'
+ categories, grouped_issues, milestone, milestone_description, milestone_name = get_github_issues
+
puts '=' * 80
puts
- puts <<EOF
+ release_candidate_doc = <<EOF
Subject: [ANN] Ruboto #{milestone_name} release candidate
Hi all!
The Ruboto #{milestone_name} release candidate is now available.
@@ -176,34 +197,39 @@
https://github.com/ruboto/ruboto/issues
--
The Ruboto Team
http://ruboto.org/
-
EOF
+ puts release_candidate_doc
+ File.write('RELEASE_CANDICATE_DOC', release_candidate_doc)
+
+ puts
puts '=' * 80
puts
- puts "Subject: [ANN] Ruboto #{milestone_name} released!"
- puts
- puts "The Ruboto team is pleased to announce the release of Ruboto #{milestone_name}."
- puts
- puts Ruboto::DESCRIPTION.gsub("\n", ' ').wrap
- puts
- puts "New in version #{milestone_name}:\n"
- puts
- puts milestone_description
- puts
- (categories.keys & grouped_issues.keys).each do |cat|
- puts "#{cat}:\n\n"
- grouped_issues[cat].each { |i| puts %Q{* Issue ##{i['number']} #{i['title']}}.wrap(2) }
- puts
- end
- puts "You can find a complete list of issues here:\n\n"
- puts "* https://github.com/ruboto/ruboto/issues?state=closed&milestone=#{milestone}\n\n"
- puts
- puts <<EOF
+ release_doc = <<EOF
+Subject: [ANN] Ruboto #{milestone_name} released!
+
+The Ruboto team is pleased to announce the release of Ruboto #{milestone_name}.
+
+#{Ruboto::DESCRIPTION.gsub("\n", ' ').wrap}
+
+New in version #{milestone_name}:
+
+#{milestone_description}
+
+#{(categories.keys & grouped_issues.keys).map do |cat|
+ "#{cat}:\n
+#{grouped_issues[cat].map { |i| %Q{* Issue ##{i['number']} #{i['title']}}.wrap(2) }.join("\n")}
+"
+end.join("\n")}
+You can find a complete list of issues here:
+
+* https://github.com/ruboto/ruboto/issues?state=closed&milestone=#{milestone}
+
+
Installation:
To use Ruboto, you need to install a Ruby implementation. Then do
(possibly as root/administrator)
@@ -217,11 +243,11 @@
ruboto setup
To run an emulator for your project
cd <project directory>
- rake emulator
+ ruboto emulator
To run your project
cd <project directory>
rake install start
@@ -235,13 +261,38 @@
--
The Ruboto Team
http://ruboto.org/
-
EOF
+
+ puts release_doc
+ puts
puts '=' * 80
+
+ unless Gem::Version.new(Ruboto::VERSION).prerelease?
+ header = <<EOF
+---
+title : Ruboto #{Ruboto::VERSION}
+layout: post
+---
+EOF
+ File.write('RELEASE_DOC', release_doc)
+ Dir.chdir BLOG_DIR do
+ output = `git status --porcelain`
+ old_blog_posts = Dir[RELEASE_BLOG_GLOB] - [RELEASE_BLOG]
+ sh "git rm -f #{old_blog_posts.join(' ')}" unless old_blog_posts.empty?
+ File.write(RELEASE_BLOG, header + release_doc)
+ sh "git add -f #{RELEASE_BLOG}"
+ if output.empty?
+ `git commit -m "* Added release blog for Ruboto #{Ruboto::VERSION}"`
+ sh 'git push'
+ else
+ puts "Workspace not clean!\n#{output}"
+ end
+ end
+ end
end
desc 'Fetch download stats form rubygems.org'
task :stats do
require 'time'
@@ -318,18 +369,18 @@
puts "\nTotal: #{total}\n\n"
end
desc 'Push the gem to RubyGems'
-task :release => [:clean, :gem] do
+task :release => [:clean, README_FILE, :release_docs, :gem] do
output = `git status --porcelain`
raise "Workspace not clean!\n#{output}" unless output.empty?
sh "git tag #{Ruboto::VERSION}"
sh 'git push --tags'
sh "gem push #{GEM_FILE}"
Rake::Task[:example].invoke
sh "git add #{EXAMPLE_FILE}"
- sh "git commit -m '* Added example app for Ruboto #{Ruboto::VERSION} tools r#{Ruboto::SdkLocations::ANDROID_TOOLS_REVISION}' \"#{examples_glob}\""
+ sh "git commit -m '* Added example app for Ruboto #{Ruboto::VERSION} tools r#{Ruboto::SdkLocations::ANDROID_TOOLS_REVISION}' \"#{EXAMPLES_GLOB}\""
sh 'git push'
end
desc "Run the tests. Select which test files to load with 'rake test TEST=test_file_pattern'"
task :test do