-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
172 lines (143 loc) · 4.32 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
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
94
95
96
97
98
99
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
namespace :test do
desc "Run All Tests"
task :all => ['tml'] do |name|
if $success
puts "\033[0;32m** Test '#{name}' finished successfully."
else
puts "\033[0;31m! Test '#{name}' failed!"
end
end
desc "TMLKit Tests"
task :tml do
$success = system("xctool -workspace TMLKit/TMLKit.xcworkspace -scheme 'TMLKit' -sdk iphonesimulator -configuration Release GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES test -test-sdk iphonesimulator")
end
end
namespace :build do
desc "Run All Builds"
task :all => ['demo', 'tmlsandbox'] do |name|
if $success
puts "\033[0;32m** Build '#{name}' finished successfully."
else
puts "\033[0;31m! Build '#{name}' failed!"
end
end
desc "Demo Build"
task :demo do
$success = system("xctool -workspace Demo/Demo.xcworkspace -scheme 'Demo' -sdk iphonesimulator -configuration Release build")
end
desc "TMLSandbox Build"
task :tmlsandbox do
$success = system("xctool -workspace TMLSandbox/TMLSandbox.xcworkspace -scheme 'TMLSandbox' -sdk iphonesimulator -configuration Release build")
end
end
namespace :info do
desc "All Info"
task :all => [:versions] do
end
desc "Informational details"
task :versions do
puts "#{podspec_path} v.#{podspec_version}"
puts "TMLKit v.#{tml_version}"
end
desc "Environment"
task :env do
ENV.each {|k,v|
puts "#{k} => #{v}"
}
end
end
desc "Execute all test and build tasks"
task :all => ['info:all', 'test:all', 'build:all'] do
end
task :default => 'all'
task :version do
git_remotes = `git remote`.strip.split("\n")
if git_remotes.count > 0
puts "-- fetching version number from github"
sh 'git fetch'
remote_version = remote_podspec_version
end
if remote_version.nil?
puts "There is no current released version. You're about to release a new Pod."
version = "0.0.1"
else
puts "The current released version of your pod is " + remote_podspec_version.to_s()
version = suggested_version_number
end
puts "Enter the version you want to release (" + version + ") "
new_version_number = $stdin.gets.strip
if new_version_number == ""
new_version_number = version
end
replace_version_number(new_version_number)
end
desc "Release a new version of the Pod"
task :release do
puts "* Running version"
sh "rake version"
unless ENV['SKIP_CHECKS']
if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master'
$stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release."
exit 1
end
if `git tag`.strip.split("\n").include?(podspec_version)
$stderr.puts "[!] A tag for version `#{podspec_version}' already exists. Change the version in the podspec"
exit 1
end
puts "You are about to release `#{podspec_version}`, is that correct? [y/n]"
exit if $stdin.gets.strip.downcase != 'y'
end
puts "* Linting the podspec"
sh "pod lib lint"
# Then release
sh "git commit #{podspec_path} CHANGELOG.md -m 'Release #{podspec_version}'"
sh "git tag -a #{podspec_version} -m 'Release #{podspec_version}'"
sh "git push origin master"
sh "git push origin --tags"
sh "pod push master #{podspec_path}"
end
# @return [String] TMLKit version
#
def tml_version
result = `plutil -p TMLKit/TMLKit/Info.plist | grep "CFBundleShortVersionString" | sed -E "s/[^0-9\.]+//g"`
result
end
# @return [Pod::Version] The version as reported by the Podspec.
#
def podspec_version
require 'cocoapods'
spec = Pod::Specification.from_file(podspec_path)
spec.version
end
# @return [Pod::Version] The version as reported by the Podspec from remote.
#
def remote_podspec_version
require 'cocoapods-core'
if spec_file_exist_on_remote?
remote_spec = eval(`git show origin/master:#{podspec_path}`)
remote_spec.version
else
nil
end
end
# @return [Bool] If the remote repository has a copy of the podpesc file or not.
#
def spec_file_exist_on_remote?
test_condition = `if git rev-parse --verify --quiet origin/master:#{podspec_path} >/dev/null;
then
echo 'true'
else
echo 'false'
fi`
'true' == test_condition.strip
end
# @return [String] The relative path of the Podspec.
#
def podspec_path
podspecs = Dir.glob('TMLKit.podspec')
if podspecs.count == 1
podspecs.first
else
raise "Could not select a podspec"
end
end