-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
101 lines (85 loc) · 2.79 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
def workspace
return 'Astro.xcworkspace'
end
def configuration
return 'Debug'
end
def targets
return [
:ios,
# :tvos # Note: we're omiting this until Circle supports testing on tvOS simulators.
]
end
def schemes
return {
ios: 'Astro',
tvos: 'Astro'
}
end
def sdks
return {
ios: 'iphonesimulator',
tvos: 'appletvsimulator9.2'
}
end
def devices
return {
ios: "platform='iOS Simulator',OS='10.2',name='iPhone 7'",
tvos: "name='Apple TV 1080p'"
}
end
def xcodebuild_astro(tasks, platform, xcpretty_args: '')
sdk = sdks[platform]
scheme = schemes[platform]
destination = devices[platform]
sh "set -o pipefail && xcodebuild CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= PROVISIONING_PROFILE= -workspace '#{workspace}' -scheme '#{scheme}' -sdk #{sdk} -destination #{destination} #{tasks} | xcpretty -c #{xcpretty_args}"
end
desc 'Build the Astro framework.'
task :build do
xcodebuild_astro 'build', :ios
end
desc 'Clean build directory.'
task :clean do
xcodebuild_astro 'clean', :ios
end
desc 'Build, then run tests.'
task :test do
targets.map { |platform| xcodebuild_astro 'build test', platform, xcpretty_args: '--test' }
sh "killall Simulator"
end
desc 'Release a version, specified as an argument.'
task :release, :version do |task, args|
version = args[:version]
abort "You must specify a version in semver format." if version.nil? || version.scan(/\d+\.\d+\.\d+/).length == 0
puts "Validating local github state"
git_status = `git status -b`
if (git_status.include? "up to date with 'origin/master'.") && (git_status.include? "nothing to commit, working tree clean
")
puts "Updating podspec."
filename = "Astro.podspec"
contents = File.read(filename)
contents.gsub!(/s\.version\s*=\s"\d+\.\d+\.\d+"/, "s.version = \"#{version}\"")
File.open(filename, 'w') { |file| file.puts contents }
puts "Comitting, tagging, and pushing."
message = "Releasing version #{version}."
sh "git commit -am '#{message}'"
sh "git tag #{version} -m '#{message}'"
sh "git push --follow-tags"
puts "Pushing to Astro.podspec"
sh "pod trunk push Astro.podspec"
puts "Pushing as a GitHub Release."
require 'octokit'
Octokit::Client.new(netrc: true).
create_release('RobotsAndPencils/Astro',
version,
name: version)
else
puts "**********************************************************************"
puts "You need to run this command on Github master with no changes present!"
puts "Check the following output to verify your local github state..."
puts "******************************* OUTPUT *******************************"
puts git_status
puts "**********************************************************************"
require 'octokit'
end
end