forked from twitter-archive/CocoaSPDY
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
56 lines (49 loc) · 1.87 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
require 'rubygems'
require 'bundler'
Bundler.setup
require 'xctasks/test_task'
require 'erb'
require 'highline/import'
XCTasks::TestTask.new do |t|
t.workspace = 'CocoaSPDY.xcworkspace'
t.schemes_dir = 'SPDYUnitTests/Schemes'
t.runner = :xcpretty
t.subtasks = { ios: 'CocoaSPDYTests' }
end
class PodRelease
attr_accessor :name, :version, :tag
def initialize(options = {})
options.each { |k,v| self.send("#{k}=", v) }
end
def filename
"#{name}.podspec"
end
def get_binding
binding
end
end
desc "Tag a new release of CocoaSPDY-Layer"
task :release do
current_branch = `git symbolic-ref --short HEAD`.chomp
fail "Release can only be tagged from `master` or `layer`" unless %w{layer master}.include?(current_branch)
version = Time.now.strftime('%Y%m%d%H%M%S%3N').to_i
pod_release = PodRelease.new(name: 'CocoaSPDY-Layer', version: version, tag: version)
erb = ERB.new(File.read(File.join(File.dirname(__FILE__), '.podspec.erb')))
File.open(pod_release.filename, 'w+') { |f| f << erb.result(pod_release.get_binding) }
say "Wrote podspec version #{pod_release.version} to #{pod_release.filename}"
system("git add #{pod_release.filename}")
response = ask("Review diff? (y/n) ") { |q| q.in = %w{y n} }
system "git diff --cached" if response == 'y'
response = ask("Commit changes? (y/n) ") { |q| q.in = %w{y n} }
system "git commit -m 'Updated podspec to #{version}'" if response == 'y'
response = ask("Tag release? (y/n) ") { |q| q.in = %w{y n} }
system "git tag #{version}" if response == 'y'
response = ask("Push release? (y/n) ") { |q| q.in = %w{y n} }
if response == 'y'
system "git push origin #{current_branch} --tags"
if $?.exitstatus.zero?
puts "Executing `pod repo push layer #{pod_release.filename}`"
Bundler.with_clean_env { system "pod repo push layer #{pod_release.filename}" }
end
end
end