class Builderator::Tasks::Version

Tasks to detect and increment package versions

Public Class Methods

exit_on_failure?() click to toggle source
# File lib/builderator/tasks/version.rb, line 15
def self.exit_on_failure?
  true
end

Public Instance Methods

bump(type = :auto, prerelease_name = nil) click to toggle source
# File lib/builderator/tasks/version.rb, line 38
def bump(type = :auto, prerelease_name = nil)
  # Workaround for singleton git provider not supporting alternate path.
  ENV['GIT_DIR'] = options[:git_dir] if options[:git_dir]

  ## Guard: Don't try to create a new version if `create_tags` is explicitly disabled
  ## or `search_tags` is disabled as we won't have a valid current version to increment
  unless Config.autoversion.create_tags && Config.autoversion.search_tags
    say_status :disabled, 'Tag creation is disabled for this build. Not '\
    'creating new SCM tags!', :red

    ## Try to read the current version anyway, incase `search_tags == true`
    current

    return
  end

  say_status :bump, "by #{type} version"
  Control::Version.bump(type, prerelease_name)

  ## Print the new version and write out a VERSION file
  current

  ## Try to create and push a tag
  run "git tag #{Control::Version.current}"
  run 'git push --tags'
end
current() click to toggle source
# File lib/builderator/tasks/version.rb, line 22
def current
  # Workaround for singleton git provider not supporting alternate path.
  ENV['GIT_DIR'] = options[:git_dir] if options[:git_dir]

  unless Config.autoversion.search_tags
    say_status :disabled, 'Automatically detecting version information '\
                          'from SCM tags is disabled', :red
    return
  end

  say_status :version, "#{Control::Version.current} (#{Control::Version.current.ref})"
  Control::Version.write
  Control::Version.set_config_version
end