Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 154 lines (124 sloc) 3.25 kb
a6a7c64 @ddollar clean up rakefile, set up multiple-build system
ddollar authored
1 require "rubygems"
2 require "bundler/setup"
ffdd401 @adamwiggins init
adamwiggins authored
3
a6a7c64 @ddollar clean up rakefile, set up multiple-build system
ddollar authored
4 PROJECT_ROOT = File.expand_path("..", __FILE__)
5 $:.unshift "#{PROJECT_ROOT}/lib"
ffdd401 @adamwiggins init
adamwiggins authored
6
a6a7c64 @ddollar clean up rakefile, set up multiple-build system
ddollar authored
7 require "heroku/version"
8 require "rspec/core/rake_task"
127160b @adamwiggins rcov rake task
adamwiggins authored
9
a6a7c64 @ddollar clean up rakefile, set up multiple-build system
ddollar authored
10 desc "Run all specs"
11 RSpec::Core::RakeTask.new(:spec) do |t|
12 t.verbose = true
800e611 @ddollar package task to create a standalone tarball
ddollar authored
13 end
14
e5b595a @ddollar cleanup
ddollar authored
15 task :default => :spec
16
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
17 ## dist
caebcd0 @ddollar windows build
ddollar authored
18
35b00d0 @ddollar consolidate deb package, move into new build system
ddollar authored
19 require "erb"
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
20 require "fileutils"
21 require "tmpdir"
746aa11 @ddollar first attempt at packaging in a single file
ddollar authored
22
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
23 def assemble(source, target, perms=0644)
24 FileUtils.mkdir_p(File.dirname(target))
35b00d0 @ddollar consolidate deb package, move into new build system
ddollar authored
25 File.open(target, "w") do |f|
26 f.puts ERB.new(File.read(source)).result(binding)
27 end
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
28 File.chmod(perms, target)
29 end
800e611 @ddollar package task to create a standalone tarball
ddollar authored
30
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
31 def assemble_distribution(target_dir=Dir.pwd)
32 distribution_files.each do |source|
33 target = source.gsub(/^#{project_root}/, target_dir)
34 FileUtils.mkdir_p(File.dirname(target))
35 FileUtils.cp(source, target)
99ff32d @ddollar add zip packaging
ddollar authored
36 end
37 end
800e611 @ddollar package task to create a standalone tarball
ddollar authored
38
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
39 GEM_BLACKLIST = %w( bundler heroku )
393ecde @ddollar add debian/apt build
ddollar authored
40
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
41 def assemble_gems(target_dir=Dir.pwd)
42 lines = %x{ bundle show }.strip.split("\n")
43 raise "error running bundler" unless $?.success?
1b538c4 @ddollar .pkg building
ddollar authored
44
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
45 %x{ env BUNDLE_WITHOUT="development:test" bundle show }.split("\n").each do |line|
46 if line =~ /^ \* (.*?) \((.*?)\)/
47 next if GEM_BLACKLIST.include?($1)
48 puts "vendoring: #{$1}-#{$2}"
49 gem_dir = %x{ bundle show #{$1} }.strip
50 FileUtils.mkdir_p "#{target_dir}/vendor/gems"
51 %x{ cp -R "#{gem_dir}" "#{target_dir}/vendor/gems" }
52 end
53 end.compact
54 end
caebcd0 @ddollar windows build
ddollar authored
55
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
56 def beta?
57 Heroku::VERSION.to_s =~ /pre/
58 end
59
60 def clean(file)
61 rm file if File.exists?(file)
62 end
746aa11 @ddollar first attempt at packaging in a single file
ddollar authored
63
d66258b @ddollar
ddollar authored
64 def distribution_files(type=nil)
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
65 require "heroku/distribution"
d66258b @ddollar
ddollar authored
66 base_files = Heroku::Distribution.files
67 type_files = type ?
68 Dir[File.expand_path("../dist/resources/#{type}/**/*", __FILE__)] :
69 []
235e439 @ddollar switch back to base_files for now until i can figure out why it's buildi...
ddollar authored
70 #base_files.concat(type_files)
71 base_files
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
72 end
73
74 def mkchdir(dir)
75 FileUtils.mkdir_p(dir)
76 Dir.chdir(dir) do |dir|
77 yield(File.expand_path(dir))
f8fc1e1 @ddollar allow packaging plugins
ddollar authored
78 end
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
79 end
80
81 def pkg(filename)
8b01021 @geemus create 'pkg' directory during build
geemus authored
82 FileUtils.mkdir_p("pkg")
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
83 File.expand_path("../pkg/#{filename}", __FILE__)
84 end
85
86 def project_root
87 File.dirname(__FILE__)
88 end
89
90 def resource(name)
91 File.expand_path("../dist/resources/#{name}", __FILE__)
92 end
67a793d @geemus Revert "replace aws/s3 with fog"
geemus authored
93
94 def s3_connect
95 return if @s3_connected
96
97 require "aws/s3"
746aa11 @ddollar first attempt at packaging in a single file
ddollar authored
98
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
99 unless ENV["HEROKU_RELEASE_ACCESS"] && ENV["HEROKU_RELEASE_SECRET"]
100 puts "please set HEROKU_RELEASE_ACCESS and HEROKU_RELEASE_SECRET in your environment"
101 exit 1
99ff32d @ddollar add zip packaging
ddollar authored
102 end
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
103
67a793d @geemus Revert "replace aws/s3 with fog"
geemus authored
104 AWS::S3::Base.establish_connection!(
105 :access_key_id => ENV["HEROKU_RELEASE_ACCESS"],
106 :secret_access_key => ENV["HEROKU_RELEASE_SECRET"]
29ce2b1 @geemus replace aws/s3 with fog
geemus authored
107 )
67a793d @geemus Revert "replace aws/s3 with fog"
geemus authored
108
109 @s3_connected = true
99ff32d @ddollar add zip packaging
ddollar authored
110 end
b437e9b @ddollar helper tasks for os-specific releases
ddollar authored
111
35b00d0 @ddollar consolidate deb package, move into new build system
ddollar authored
112 def store(package_file, filename, bucket="assets.heroku.com")
67a793d @geemus Revert "replace aws/s3 with fog"
geemus authored
113 s3_connect
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
114 puts "storing: #{filename}"
67a793d @geemus Revert "replace aws/s3 with fog"
geemus authored
115 AWS::S3::S3Object.store(filename, File.open(package_file), bucket, :access => :public_read)
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
116 end
b437e9b @ddollar helper tasks for os-specific releases
ddollar authored
117
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
118 def tempdir
119 Dir.mktmpdir do |dir|
120 Dir.chdir(dir) do
121 yield(dir)
122 end
123 end
124 end
125
126 def version
127 require "heroku/version"
128 Heroku::VERSION
129 end
b437e9b @ddollar helper tasks for os-specific releases
ddollar authored
130
e58805c @ddollar use rake's actual feature set to build releases
ddollar authored
131 Dir[File.expand_path("../dist/**/*.rake", __FILE__)].each do |rake|
132 import rake
b437e9b @ddollar helper tasks for os-specific releases
ddollar authored
133 end
d5fc1ee @geemus add rake task to poll ci status
geemus authored
134
135 def poll_ci
136 require("vendor/heroku/okjson")
137 require("net/http")
138 data = Heroku::OkJson.decode(Net::HTTP.get("travis-ci.org", "/heroku/heroku.json"))
139 case data["last_build_status"]
140 when nil
141 print(".")
142 sleep(1)
143 poll_ci
144 when 0
145 puts("SUCCESS")
146 when 1
147 puts("FAILURE")
148 end
149 end
150
151 task "ci" do
152 poll_ci
153 end
Something went wrong with that request. Please try again.