Sha256: 6f40684a4f5b1b4be41be9e6eea16fd5d4a1fd2d4c0b163ac0260aaa4bb849f9

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module GoNative
  module Commands
    module Android
      class  Publish < Base
        desc 'Used to update one of the android internal dependencies'
        
        def call
          assert_build_file_exists!
          create_and_push_tag!
        end
        
        def assert_build_file_exists!
          return unless gradle_files.empty?

          raise Error, "No build.gradle file exists"
        end
        
        private
        
        def gradle_files
          @gradle_files ||= `find . -iname build.gradle`.split("\n")
        end

        def version
          return @version if @version
          
          gradle_files.each do |gradle_file|
            str = IO.read(gradle_file)
            @version = str.match(/versionName\s+\"(?<version>.+)\"/)[:version]
            
            break if @version
          end

          @version
        end

        def create_and_push_tag!
          unless system("git tag | grep #{version} > /dev/null")
            system "git add -A && git commit -m \"Releases #{version}.\""
            system "git tag #{version}"
            system "git push && git push --tags"
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gonative-cli-1.1.2 lib/gonative/commands/android/publish.rb
gonative-cli-1.1.1 lib/gonative/commands/android/publish.rb
gonative-cli-1.1.0 lib/gonative/commands/android/publish.rb
gonative-cli-1.0.6 lib/gonative/commands/android/publish.rb
gonative-cli-1.0.5 lib/gonative/commands/android/publish.rb