Skip to content

Commit

Permalink
Merge pull request ManageIQ#78 from Fryguy/split_rake_release
Browse files Browse the repository at this point in the history
Add rake release task
  • Loading branch information
bdunne authored Mar 28, 2017
2 parents 609fb1e + b81c71d commit 4390299
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
14 changes: 1 addition & 13 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'manageiq-content'
ManageIQ::Content::Engine.load_tasks

begin
require 'rspec/core/rake_task'
Expand All @@ -11,17 +10,6 @@ begin
rescue LoadError
end

if defined?(RSpec) && defined?(RSpec::Core::RakeTask)
namespace :spec do
desc "Setup environment for specs"
task :setup => ["app:test:initialize", "app:test:verify_no_db_access_loading_rails_environment", "app:test:setup_db"]
end

RSpec::Core::RakeTask.new(:spec => ["app:test:initialize", "app:evm:compile_sti_loader"]) do |t|
spec_dir = File.expand_path("spec", __dir__)
EvmTestHelper.init_rspec_task(t, ['--require', File.join(spec_dir, 'spec_helper')])
t.pattern = FileList[spec_dir + '/**/*_spec.rb'].exclude(spec_dir + '/manageiq/**/*_spec.rb')
end
end
FileList['lib/tasks_private/**/*.rake'].each { |r| load r }

task :default => :spec
Empty file added lib/tasks/.gitkeep
Empty file.
File renamed without changes.
40 changes: 40 additions & 0 deletions lib/tasks_private/release.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Rake::Task[:release].clear

desc "Release a new project version"
task :release do
require 'pathname'
require 'yaml'
require 'more_core_extensions/core_ext/hash/nested'

version = ENV["RELEASE_VERSION"]
if version.nil? || version.empty?
STDERR.puts "ERROR: You must set the env var RELEASE_VERSION to the proper value."
exit 1
end

branch = `git rev-parse --abbrev-ref HEAD`.chomp
if branch == "master"
STDERR.puts "ERROR: You cannot cut a release from the master branch."
exit 1
end

root = Pathname.new(__dir__).join("../..")

# Modify the automate domain version
ae_file = root.join("content/automate/ManageIQ/System/About.class/__class__.yaml")
content = YAML.load_file(ae_file)
content.store_path("object", "schema", 0, "field", "default_value", version)
File.write(ae_file, content.to_yaml)

# Create the commit and tag
exit $?.exitstatus unless system("git add #{version_file}")
exit $?.exitstatus unless system("git commit -m 'Release #{version}'")
exit $?.exitstatus unless system("git tag #{version}")

puts
puts "The commit on #{branch} with the tag #{version} has been created"
puts "Run the following to push to the upstream remote:"
puts
puts "\tgit push upstream #{branch} #{version}"
puts
end
10 changes: 10 additions & 0 deletions lib/tasks_private/spec.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace :spec do
desc "Setup environment for specs"
task :setup => ["app:test:initialize", "app:test:verify_no_db_access_loading_rails_environment", "app:test:setup_db"]
end

RSpec::Core::RakeTask.new(:spec => ["app:test:initialize", "app:evm:compile_sti_loader"]) do |t|
spec_dir = File.expand_path("../../spec", __dir__)
EvmTestHelper.init_rspec_task(t, ['--require', File.join(spec_dir, 'spec_helper')])
t.pattern = FileList[spec_dir + '/**/*_spec.rb'].exclude(spec_dir + '/manageiq/**/*_spec.rb')
end

0 comments on commit 4390299

Please sign in to comment.