Sha256: c6159b5c2983ba03bd61ac63b25609fb2c6f72c95ca2dc3ee624715835a7eb02

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

require 'thor'

require_relative '../patch/thor-actions'
require_relative '../control/version'
require_relative '../util'

module Builderator
  module Tasks
    ##
    # Tasks to detect and increment package versions
    ##
    class Version < Thor
      include Thor::Actions

      def self.exit_on_failure?
        true
      end

      desc 'current', 'Print the current version and write it to file'
      def current
        unless Config.autoversion.search_tags
          say_status :disabled, 'Automatically detecting version informantion '\
                                '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

      desc 'bump TYPE [PRERELEASE_NAME]', 'Increment the package version, optionally with a named prerelease'
      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 valud 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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
builderator-1.0.0.pre.rc.4 lib/builderator/tasks/version.rb
builderator-1.0.0.pre.rc.3 lib/builderator/tasks/version.rb
builderator-1.0.0.pre.rc.1 lib/builderator/tasks/version.rb