Class: XcodeBuilder::ReleaseStrategies::Git

Inherits:
ReleaseStrategy show all
Defined in:
lib/xcode_builder/release_strategies/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ReleaseStrategy

#configure, #initialize

Constructor Details

This class inherits a constructor from XcodeBuilder::ReleaseStrategies::ReleaseStrategy

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



4
5
6
# File 'lib/xcode_builder/release_strategies/git.rb', line 4

def branch
  @branch
end

#originObject

Returns the value of attribute origin.



4
5
6
# File 'lib/xcode_builder/release_strategies/git.rb', line 4

def origin
  @origin
end

#tag_nameObject

Returns the value of attribute tag_name.



4
5
6
# File 'lib/xcode_builder/release_strategies/git.rb', line 4

def tag_name
  @tag_name
end

Instance Method Details

#commit_and_push_with_message(message) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/xcode_builder/release_strategies/git.rb', line 100

def commit_and_push_with_message message
   # then commit it
  cmd = []
  cmd << "git"
  cmd << "commit"
  cmd << "-m"
  cmd << "'#{message}'"
  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  system(cmd.join " ")
  puts
  puts "Done"

  # now, push the updated plist
  print "Pushing update to #{@origin}/#{@branch}"
  cmd = []
  cmd << "git"
  cmd << "push"
  cmd << @origin
  cmd << @branch
  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  
  result = system(cmd.join " ")
  raise "Could not push #{@branch} to #{@origin}" unless result
  puts 
end

#prepareObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/xcode_builder/release_strategies/git.rb', line 6

def prepare
  
  if @origin == nil then
      @origin = "origin"
  end

  if @branch == nil then
      @branch = "master"
  end

  if @tag_name == nil then
      @tag_name = "v#{@configuration.build_number}"
  end
end

#prepare_for_next_pod_releaseObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/xcode_builder/release_strategies/git.rb', line 55

def prepare_for_next_pod_release
  build_number = @configuration.build_number
  next_build_number = @configuration.next_build_number

  raise "build number cannot be empty on release" unless  (build_number != nil) && (!build_number.empty?) 

  # increment the build number
  @configuration.increment_pod_number

  # commit
  print "Committing #{@configuration.info_plist} and #{@configuration.podspec_file} with version #{build_number}"
  stage_files [@configuration.info_plist, @configuration.podspec_file]
  commit_and_push_with_message "Preparing for next pod release #{next_build_number}..."
 
  puts "Done"
end

#prepare_for_next_releaseObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/xcode_builder/release_strategies/git.rb', line 72

def prepare_for_next_release
  build_number = @configuration.build_number
  next_build_number = @configuration.next_build_number

  raise "build number cannot be empty on release" unless  (build_number != nil) && (!build_number.empty?) 
  
  # increment the build number
  @configuration.increment_plist_number
  
  print "Committing #{@configuration.info_plist} with version #{next_build_number}"

  stage_files [@configuration.info_plist]
  commit_and_push_with_message "[Xcodebuilder] Releasing build #{build_number}"
 
  puts "Done"
end

#stage_files(files) ⇒ Object



89
90
91
92
93
94
95
96
97
98
# File 'lib/xcode_builder/release_strategies/git.rb', line 89

def stage_files files
  cmd = []
  
  cmd << "git"
  cmd << "add"
  files.each do |value|
      cmd <<  value
  end
  system(cmd.join " ")
end

#tag_current_versionObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/xcode_builder/release_strategies/git.rb', line 21

def tag_current_version
  puts "Relasing with Git"
  print "Tagging version #{@tag_name}"
  cmd = []

  #first, tag
  cmd << "git"
  cmd << "tag"
  cmd << @tag_name

  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  result = system(cmd.join " ")
  raise "Could not tag repository" unless result
  puts
  puts "Done"

  # then push tags to the remote server
  print "Pushing tag to #{@origin} on branch #{@branch}"
  cmd = []

  cmd << "git"
  cmd << "push"
  cmd << "--tags"
  cmd << @origin
  cmd << @branch
  cmd << "2>&1 %s git.output" % (@configuration.verbose ? '| tee' : '>')
  system(cmd.join " ")
  raise "Could not push to #{@origin}" unless result
  
  puts
  puts "Done"

end