Commit 6c89137e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Create Rake bump task to update version number.

rake bump

    Bumps the minor version number by one.

rake bump["6.0.0"]

    Bumps to the specified version.

The version.rb file gets updated and committed.  The commit gets tagged
with the same version number.
parent 7f2be54f
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -227,6 +227,53 @@ task :sass do
  system "compass compile --quiet template/resources/sass"
end

def write_version_file(version)
  File.open('./lib/jsduck/version.rb', 'w') do |f|
    f.write(<<-EORUBY)
# This file is updated by rake bump task.
# Do not edit by hand.
module JsDuck
  VERSION = "#{version}"
end
EORUBY
  end
end

def commit_version(version)
  system "git commit lib/jsduck/version.rb -m 'Up version to #{version}.'"
  puts "Creating tag v#{version}"
  system "git tag -a v#{version} -m 'Tagging #{version} release.'"
end

desc <<-EOTEXT
Bumps JSDuck minor version number up by one.
Or sets the specified version number, when invoked like:

    rake bump['1.2.3']

Also commits and tags the change in git.
EOTEXT
task :bump, :new_version do |t, args|
  require "./lib/jsduck/version.rb"

  if args[:new_version]
    new = args[:new_version]
    puts "Bumping version from #{JsDuck::VERSION} to #{new}"
    write_version_file(new)
    commit_version(new)
  else
    if JsDuck::VERSION =~ /\A([0-9]+)\.([0-9]+)\.([0-9]+)\z/
      new = "#{$1}.#{$2}.#{$3.to_i+1}"
      puts "Bumping version from #{JsDuck::VERSION} to #{new}"
      write_version_file(new)
      commit_version(new)
    else
      puts "Unable to automatically bump the version: #{JsDuck::VERSION}"
      exit 1
    end
  end
end

desc "Build JSDuck gem"
task :gem => :sass do
  compress
+2 −0
Original line number Diff line number Diff line
# This file is updated by rake bump task.
# Do not edit by hand.
module JsDuck
  VERSION = "5.3.3"
end