Sha256: 0347c97da58913ef78e933128e7dc8e00639b28620b5b1a3a6bb4a1a3dcd6da9

Contents?: true

Size: 1.88 KB

Versions: 22

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true

require 'cocoapods'

module GoNative
  module Plugins
    module IOS
      class Release
        extend DSL::Serviceable
        
        GONATIVE_SOURCE_NAME = 'gonative-specs'.freeze
  
        def call
          Utils::UI.info 'Linting and releasing pod'
          assert_spec_exists!
          sources_manager.update(GONATIVE_SOURCE_NAME)
          assert_not_pushed!
          create_and_push_tag!
          push_to_pod_repo!
        end
  
        private
    
          def assert_spec_exists!
            return if spec_name
            
            raise Error, "No podspec file exists"
          end

          def assert_not_pushed!
            version = spec.version
            name = spec.name
  
            pushed_versions = source.versions(name)&.collect(&:to_s)
  
            raise Error, "#{name} (#{version}) has already been pushed to #{source.name}" if pushed_versions&.include? version.to_s
          end

          def create_and_push_tag!
            unless system("git tag | grep #{spec.version} > /dev/null")
              system "git add -A && git commit -m \"Releases #{spec.version}.\""
              system "git tag #{spec.version}"
              system "git push && git push --tags"
            end
          end
          
          def push_to_pod_repo!
            system "pod repo push #{GONATIVE_SOURCE_NAME} #{spec_name} --private"
          end
          
          def spec_name
            @spec_name ||= Dir.entries(".").select { |s| s.end_with? ".podspec" }.first
          end
          
          def spec
            @spec ||= Pod::Specification.from_file(spec_name)
          end
          
          def source
            @source ||= sources_manager.source_with_name_or_url(GONATIVE_SOURCE_NAME)
          end
          
          def sources_manager
            Pod::Config.instance.sources_manager
          end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
gonative-cli-0.8.0 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.17 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.16 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.15 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.14 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.13 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.12 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.11 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.10 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.9 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.8 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.7 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.6 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.5 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.4 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.3 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.2 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.1 lib/gonative/plugins/ios/release.rb
gonative-cli-0.7.0 lib/gonative/plugins/ios/release.rb
gonative-cli-0.6.0 lib/gonative/plugins/ios/release.rb