Class: DYAutomate::Command::Pod::Push

Inherits:
DYAutomate::Command::Pod show all
Defined in:
lib/DYAutomate/Command/Pod/push.rb

Instance Attribute Summary

Attributes inherited from DYAutomate::Command::Pod

#name, #path, #spec_name, #spec_path

Attributes inherited from DYAutomate::Command

#config, #env_str, #repo_name

Instance Method Summary collapse

Methods inherited from DYAutomate::Command::Pod

#dy_update_repo, #existPodspec?, #file_line_match, #file_line_match_replace, #get_spec_version, #get_version_big_new, #get_version_new

Methods inherited from DYAutomate::Command

#pp

Constructor Details

#initialize(argv) ⇒ Push

#要查询的lib名字attr_accessor :name #查询结果lib信息attr_accessor :info



21
22
23
24
# File 'lib/DYAutomate/Command/Pod/push.rb', line 21

def initialize(argv)
  # @name = argv.shift_argument
  super
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/DYAutomate/Command/Pod/push.rb', line 37

def run
  pp('push run ...',1)

  Dir.chdir(@path)
  new_v = get_spec_version

  isTagOk = true
  retry_time = 2

  #git 处理
  begin
    isTagOk = system "git add ."
    isTagOk = system "git commit -m \"修改版本号 ->#{new_v}\""
    isTagOk = system "git push"
    unless isTagOk
      retry_time.times{
         pp('retry push ...',1)
         isTagOk = system "git push"
         system 'sleep 2'
      }
    end

    if isTagOk
      isTagOk = system "git tag -a #{new_v} -m '升级tag'"
      isTagOk = system "git push --tags"
      unless isTagOk
         retry_time.times{
            pp('retry push tags ...',1)
            isTagOk = system "git push --tags"
            system 'sleep 2'
        }
      end
    end
  rescue
    isTagOk = false
    pp("Errror git --- #{@name} --- #{new_v}", 2)
  end

  if isTagOk
    #push 到repo仓库
    dy_update_repo

    pp('私有库repo ->' + @repoName,1)
    pp("环境变量 -->"+@env_str,1)

    isok = system "#{@env_str} pod repo push #{@repoName} \
      --sources='master',#{@repoName} \
      --use-libraries \
      --allow-warnings \
      --verbose"
    unless isok
      system "git reset --hard "
      system "git tag -d #{new_v}"
      system "git push origin -d #{new_v}"
    end
  end
end

#validate!Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/DYAutomate/Command/Pod/push.rb', line 26

def validate!
  super
  # unless @name
  #   help! 'need the lib `NAME`.'
  # end

  # unless existAtPools?
  #   help! "the podspec file is not exist at #{Dir.pwd}."
  # end
end