Sha256: 2680759d349360bfd0f0fd784506456669229bf414802d45665f4ee98f4b096c

Contents?: true

Size: 1.71 KB

Versions: 9

Compression:

Stored size: 1.71 KB

Contents

def version
  version_file = File.join(File.dirname(__FILE__), "lib", name, "version.rb")
  contents = File.read(version_file)
  contents.match(/VERSION = ['"]([0-9a-z.-]+)['"].*$/)
  $1
end

def name
  "<%= @gem_name %>"
end

def built_gem_path
  gem_packages = File.join(File.dirname(__FILE__), "pkg", "#{name}-*.gem")
  Dir[gem_packages].sort_by { |file| File.mtime(file) }.last
end

def already_tagged?
  `git tag`.split(/\n/).include?("v#{version}")
end

desc "Build #{name}-#{version}.gem into the pkg directory."
task 'build' do
  `gem build -V #{File.join(File.dirname(__FILE__), "#{name}.gemspec")}`
  FileUtils.mkdir_p(File.join(File.dirname(__FILE__), "pkg"))
  gem = Dir[File.join(File.dirname(__FILE__), "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
  FileUtils.mv(gem, 'pkg')
  puts "#{name} #{version} built to #{built_gem_path}."
end

desc "Build and install #{name}-#{version}.gem into system gems."
task 'install' => 'build' do
  `gem install '#{built_gem_path}' --local`
end

desc "Create tag v#{version} and build and push #{name}-#{version}.gem to Rubygems\n" \
     "To prevent publishing in Rubygems use `gem_push=no rake release`"
task 'release' => ['build', 'release:guard_clean',
                   'release:source_control_push', 'release:rubygem_push'] do
end

task 'release:guard_clean' do
  if !system("git diff --exit-code") || !system("git diff-index --quiet --cached HEAD")
    puts "There are files that need to be committed first."
    exit(1)
  end
end

task 'release:source_control_push' do
  unless already_tagged?
    system "git tag -a -m 'Version #{version}' v#{version}"
    system 'git push'
    system 'git push --tags'
  end
end

task 'release:rubygem_push' do
  system "gem push #{built_gem_path}"
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
nesta-0.18.0 templates/plugins/Rakefile
nesta-0.17.0 templates/plugins/Rakefile
nesta-0.16.0 templates/plugins/Rakefile
nesta-0.15.0 templates/plugins/Rakefile
nesta-0.14.0 templates/plugins/Rakefile
nesta-0.13.0 templates/plugins/Rakefile
nesta-0.12.0 templates/plugins/Rakefile
nesta-0.11.1 templates/plugins/Rakefile
nesta-0.11.0 templates/plugins/Rakefile