Class: Horatio::Releaser
- Inherits:
-
Object
- Object
- Horatio::Releaser
- Defined in:
- lib/horatio/releaser.rb
Instance Attribute Summary collapse
-
#release ⇒ Object
Returns the value of attribute release.
-
#vcs ⇒ Object
Returns the value of attribute vcs.
Instance Method Summary collapse
- #generate_artifact ⇒ Object
-
#initialize(options = {}) ⇒ Releaser
constructor
A new instance of Releaser.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Releaser
Returns a new instance of Releaser.
8 9 10 11 12 13 14 |
# File 'lib/horatio/releaser.rb', line 8 def initialize(={}) @options = @registry = @options['registry'] @release = Horatio::Detector.detect color { Log.info "detected #{@release.description}" } @vcs = Horatio::VCS.detect(@options) end |
Instance Attribute Details
#release ⇒ Object
Returns the value of attribute release.
6 7 8 |
# File 'lib/horatio/releaser.rb', line 6 def release @release end |
#vcs ⇒ Object
Returns the value of attribute vcs.
6 7 8 |
# File 'lib/horatio/releaser.rb', line 6 def vcs @vcs end |
Instance Method Details
#generate_artifact ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/horatio/releaser.rb', line 16 def generate_artifact contents = JSON.pretty_generate({'name' => @release.name, 'version' => "#{@release.version}-#{@vcs.latest_revision}", 'app_version' => @release.version, 'source_revision' => @vcs.latest_revision, 'url' => "#{@registry}/#{@release.name}:#{@release.version}-#{@vcs.latest_revision}"}) File.open('docker-image.json', 'w') { |f | f.write(contents); } end |
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/horatio/releaser.rb', line 26 def run color { Log.info "Running Docker build for #{@release.name}-#{@release.version}" } @release.validate color { Log.info "latest revision is #{@vcs.latest_revision }" } no_cache = ENV['DOCKER_BUILD_NO_CACHE'] ? "--no-cache " : "" run_sh "docker build " + no_cache + "-t #{@registry}/#{@release.name}:#{@release.version}-#{@vcs.latest_revision} ." run_sh "docker push #{@registry}/#{@release.name}" generate_artifact @release.increment(self) return true end |