Sha256: 6dccfd842cd7f0d07321ae41ee49655f154ea9fae6a5a1b8d68cb43b6d206e6b

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

module Phase
  module CLI
    class Build < Command

      command :build do |c|
        c.syntax = "phase build [-s]"

        c.option "-s", "--sandbox", String, "Build in sandbox mode: uses current directory's possibly dirty git tree as build context."

        c.description = <<-EOS.strip_heredoc
          Builds a new Docker image of the latest committed code on the current branch. Tags the
          build with <version_number>.
        EOS

        c.action do |args, options|
          options.default(sandbox: false)
          new(args, options).run
        end
      end

      attr_reader :clean_build, :version_number

      def initialize(args, options)
        super
        @clean_build = !options.sandbox
      end

      def run
        version_number = get_next_version_number

        build = ::Phase::Deploy::Build.new(version_number, clean_build: clean_build)
        build.execute!
      end

      private

        def get_next_version_number
          current_version = ::Phase::Deploy::Version.current

          log "Last release was version #{ current_version.magenta }." if current_version

          input = ask "New version number:"
          fail "Version number is required" if input.blank?
          input
        end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
phase-1.0.1 lib/phase/cli/build.rb
phase-1.0.0 lib/phase/cli/build.rb
phase-1.0.0.rc2 lib/phase/cli/build.rb
phase-1.0.0.rc1 lib/phase/cli/build.rb