Sha256: 249e3587591699e7f576f045655f0e57206602342df065714d7fc27cf8df3a3b

Contents?: true

Size: 1.6 KB

Versions: 18

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

require 'cocoapods'

module GoNative
  module Plugins
    module IOS
      class Release
        extend DSL::Serviceable
        include Helpers::SpecReader

        GONATIVE_SOURCE_NAME = 'gonative-specs'

        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)

          if pushed_versions&.include? version.to_s
            raise Error,
                  "#{name} (#{version}) has already been pushed to #{source.name}"
          end
        end

        def create_and_push_tag!
          return if 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

        def push_to_pod_repo!
          system "pod repo push #{GONATIVE_SOURCE_NAME} #{spec_name} --private --allow-warnings"
        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

18 entries across 18 versions & 1 rubygems

Version Path
gonative-cli-1.4.4 lib/gonative/plugins/ios/release.rb
gonative-cli-1.4.2 lib/gonative/plugins/ios/release.rb
gonative-cli-1.4.1 lib/gonative/plugins/ios/release.rb
gonative-cli-1.4.0 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.9 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.8 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.7 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.6 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.5 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.4 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.3 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.2 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.1 lib/gonative/plugins/ios/release.rb
gonative-cli-1.3.0 lib/gonative/plugins/ios/release.rb
gonative-cli-1.2.4 lib/gonative/plugins/ios/release.rb
gonative-cli-1.2.3 lib/gonative/plugins/ios/release.rb
gonative-cli-1.2.2 lib/gonative/plugins/ios/release.rb
gonative-cli-1.2.1 lib/gonative/plugins/ios/release.rb