Skip to content
This repository was archived by the owner on Nov 7, 2023. It is now read-only.

Commit 1960198

Browse files
committed
Merge branch 'master' into build_no_on_icon
Conflicts: modules/bump_version_module.rb
2 parents 5c806f3 + 34125d5 commit 1960198

File tree

5 files changed

+48
-33
lines changed

5 files changed

+48
-33
lines changed

Diff for: Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ gem "ocunit2junit"
77
gem "commander"
88
gem "xcodeproj", "~> 0.9.0"
99
gem "plist", "~> 3.1.0"
10+
gem "rmagick", "~> 2.13.2"

Diff for: Gemfile.lock

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ GEM
1717
plist (3.1.0)
1818
rest-client (1.6.7)
1919
mime-types (>= 1.16)
20+
rmagick (2.13.2)
2021
xcodeproj (0.9.0)
2122
activesupport (~> 3.2.13)
2223
colored (~> 1.2)
@@ -31,4 +32,5 @@ DEPENDENCIES
3132
ocunit2junit
3233
plist (~> 3.1.0)
3334
rest-client (~> 1.6.7)
35+
rmagick (~> 2.13.2)
3436
xcodeproj (~> 0.9.0)

Diff for: docs/CONFIGURATION.md

-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ Global Configuration Parameters:
3333

3434
bump_version:
3535
enabled: false
36-
push: false
3736
up_mver: false
3837
simple: false
3938
`bump_version.enabled` **[bool]** - enable or disable module for configuration
40-
`bump_version.push` **[bool]** - push changes to git repo or not
4139
`bump_version.up_mver` **[bool]** - update marketing version field or not (semantic version format major.minor.build)
4240
`bump_version.simple` **[bool]** - update marketing version to build number
4341
4. **Build Module**

Diff for: modules/build_module.rb

+21-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
require "xcodeproj"
2+
require 'plist'
3+
require "rmagick"
4+
include Magick
25

36
class BuildModule < BaseModule
47
config_key 'build'
@@ -120,7 +123,6 @@ def self.add_version_number_to_icon config, project_name
120123
target = project.targets.select{|t| t.name == target_name}.first
121124
project_info_file = real_path(target.build_settings(config.build.configuration)['INFOPLIST_FILE'])
122125

123-
require 'Plist'
124126
begin
125127
project_info = Plist::parse_xml project_info_file
126128
icons_names = project_info['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles']
@@ -132,24 +134,26 @@ def self.add_version_number_to_icon config, project_name
132134
icons_patterns = icons_names.map do |icon|
133135
"**/#{icon}"
134136
end
135-
136-
require "rmagick"
137-
include Magick
138-
Dir[icons_patterns].each do |icon|
137+
puts icons_patterns
138+
Dir.glob(icons_patterns).each do |icon|
139139
filename = real_path icon
140140
retina = !!filename.index('@')
141-
image = Image::read(filename).first
142-
draw = Draw::new
143-
draw.annotate(image, 0, 0, 0, 0, config.runtime.version) {
144-
self.font_family = 'Arial'
145-
self.fill = 'green'
146-
self.stroke = 'black'
147-
self.pointsize = if retina then 22 else 11
148-
self.font_weight = BoldWeight
149-
self.gravity = SouthGravity
150-
self.text_antialias = true
151-
}
152-
image.write filename
141+
begin
142+
image = Image::read(filename).first
143+
draw = Draw::new
144+
draw.annotate(image, 0, 0, 0, 0, config.runtime.version) {
145+
self.font_family = 'Arial'
146+
self.fill = 'blue'
147+
self.stroke = 'black'
148+
self.pointsize = if retina then 22 else 11 end
149+
self.font_weight = BoldWeight
150+
self.gravity = SouthGravity
151+
self.text_antialias = true
152+
}
153+
image.write filename
154+
rescue Exception => e
155+
next
156+
end
153157
end
154158

155159
hook :build_complete, proc {

Diff for: modules/bump_version_module.rb

+24-14
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,35 @@ class BumpVersionModule < BaseModule
66
def self.run config
77
info "Bumping version..."
88

9+
begin
10+
system %Q[git pull origin #{config.branch.name}] or fail "failed pulling remote repos"
11+
12+
version, build_number = self.bump_version
13+
self.update_marketing_version config, version, build_number
14+
15+
system %Q[git commit -am "AUTOBUILD -- configuration: #{config.runtime.configuration}, ver: #{version}, build: #{build_number}"]
16+
info "Push updated version numbers to git"
17+
result = system %Q[git push origin #{config.branch.name}]
18+
unless result
19+
puts "\nFailed pushing data to repo, waiting 5 seconds before retry..."
20+
system %Q[git reset --hard HEAD^]
21+
sleep 5
22+
end
23+
end until result
24+
end
25+
26+
private
27+
def self.bump_version
928
system %Q[agvtool bump -all]
1029
build_number = `agvtool vers -terse`.strip
11-
1230
version = `agvtool mvers -terse1`.strip
1331
unless is_version_ok? version
14-
info "ERROR: Bad version value #{version}"
15-
info "Aborting..."
16-
return false
32+
fail "ERROR: Bad version value #{version}. Aborting..."
1733
end
18-
34+
[version, build_number]
35+
end
36+
37+
def self.update_marketing_version config, version, build_number
1938
if config.bump_version.up_mver
2039
if config.bump_version.simple?
2140
version = build_number
@@ -27,15 +46,6 @@ def self.run config
2746
end
2847
system %Q[agvtool new-marketing-version "#{version}"]
2948
end
30-
3149
config.runtime.version = version
32-
33-
if config.bump_version.push?
34-
hook :complete, proc {
35-
info "Push updated version numbers to git"
36-
system %Q[git commit -am "AUTOBUILD -- configuration: #{config.runtime.configuration}, ver: #{version}, build: #{build_number}"]
37-
system %Q[git push origin #{config.branch.name}]
38-
}
39-
end
4050
end
4151
end

0 commit comments

Comments
 (0)