Class: Builderator::Tasks::Version

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/builderator/tasks/version.rb

Overview

Tasks to detect and increment package versions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Thor::Actions

#run, #run_with_input, #run_without_bundler, #template, #thor_run

Class Method Details

.exit_on_failure?Boolean



15
16
17
# File 'lib/builderator/tasks/version.rb', line 15

def self.exit_on_failure?
  true
end

Instance Method Details

#bump(type = :auto, prerelease_name = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/builderator/tasks/version.rb', line 33

def bump(type = :auto, prerelease_name = nil)
  ## 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

#currentObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/builderator/tasks/version.rb', line 20

def current
  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