Sha256: 69d953dc9a4d37d159928ae6dc6990059b5dce98691bc8dc48ec473002ce9052

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

module Docman
  module Deployers
    class GitDeployer < Deployer

      register_deployer :git_deployer

      def push
        root = @docroot_config.root
        root.state_name = self['state']
        tag = nil

        if self['environment'].has_key?('tagger')
          filepath = File.join(root['full_build_path'], 'VERSION')
          prev_version = File.file?(filepath) ? File.open(filepath) : nil
          params = self['environment']['tagger']
          params['prev_version'] = prev_version
          version = ''
          docman_tag_var = "DOCMAN_TAG"
          docman_release_var = "RELEASE_VERSION"
          if ENV.has_key? docman_tag_var and ENV[docman_tag_var].length > 0
            puts "Variable #{docman_tag_var} => #{ENV[docman_tag_var]}"
            version = ENV[docman_tag_var]
          elsif ENV.has_key? docman_release_var and ENV[docman_release_var].length > 0
            puts "Variable #{docman_release_var} => #{ENV[docman_release_var]}"
            version = ENV[docman_release_var]
          else
            puts "Variable #{docman_release_var} or #{docman_tag_var} not found."
            version = Docman::Taggers::Tagger.create(params, root, self).perform
          end
          File.open(filepath, 'w') {|f| f.write(version) }

          filepath = File.join(root['full_build_path'], 'version.properties')
          File.open(filepath, 'w') {|f| f.write("tag=#{version}") }

          tag = version
        end

        GitUtil.commit(root['full_build_path'], root['full_build_path'], 'Updated version')
        GitUtil.squash_commits(Docman::Application.instance.commit_count, nil, tag)
        GitUtil.push(root['full_build_path'], root.version(type: 'root'))
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
docman-0.0.107 lib/docman/deployers/git_deployer.rb
docman-0.0.106 lib/docman/deployers/git_deployer.rb