Skip to content

Commit

Permalink
publish passing master builds to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetanley committed May 31, 2013
1 parent e6b6ae8 commit 265d624
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 2,642 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ vendor
.rvmrc
.DS_Store
lib/handlebars/compiler/parser.js
dist/*.min.js
dist
node_modules
*.sublime-project
*.sublime-workspace
Expand Down
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
after_success: bundle exec rake publish
env:
global:
- S3_BUCKET_NAME=builds.handlebarsjs.com
- secure: ! 'PJaukuvkBBsSDOqbIcNSSMgb96VVEaIt/eq9GPjXPeFbSd3hXgwhwVE62Lrq
tJO8BaUfX+PzpiQjEl4D5/KBmvlFZ057Hqmy0zmPOT5mDZfJe8Ja5zyvTMb+
KkCWN/tjAp8kawHojE04pn6jIpPdwXFnAYwPhaHbATFrmdt9fdg='
- secure: ! 'mBcGL2tnmiRujJdV/4fxrVd8E8wn6AW9IQKVcMv8tvOc7i5dOzZ39rpBKLuT
MRXDtMV1LyLiuKYb1pHj1IyeadEahcLYFfGygF4LG7Yzp4NWHtRzQ7Q8LXaJ
V7dXDboYCFkn2a8/Rtx1YSVh/sCONf5UoRC+MUIqrj4UiHN9r3s='
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ source "http://rubygems.org"
gem "rake"
gem "therubyracer", ">= 0.9.8", "< 0.11"
gem "rspec"
gem "aws-sdk"
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
GEM
remote: http://rubygems.org/
specs:
aws-sdk (1.10.0)
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
diff-lcs (1.1.3)
json (1.8.0)
libv8 (3.3.10.4)
nokogiri (1.5.9)
rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
Expand All @@ -14,11 +20,13 @@ GEM
rspec-mocks (2.12.1)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
uuidtools (2.1.4)

PLATFORMS
ruby

DEPENDENCIES
aws-sdk
rake
rspec
therubyracer (>= 0.9.8, < 0.11)
14 changes: 13 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Build Status](https://travis-ci.org/wycats/handlebars.js.png?branch=master)](https://travis-ci.org/wycats/handlebars.js)


Handlebars.js
=============

Expand All @@ -11,13 +12,23 @@ keep the view and the code separated like we all know they should be.
Checkout the official Handlebars docs site at
[http://www.handlebarsjs.com](http://www.handlebarsjs.com).


Installing
----------
Installing Handlebars is easy. Simply download the package [from the
official site](http://handlebarsjs.com/) and add it to your web pages
(you should usually use the most recent version).

Alternatively, if you prefer having the latest version of handlebars from
the 'master' branch, passing builds of the 'master' branch are automatically
published to S3. You may download the latest passing master build by grabbing
a `handlebars-latest.js` file from the [builds page][builds-page]. When the
build is published, it is also available as a `handlebars-gitSHA.js` file on
the builds page if you need a version to refer to others.
`handlebars-runtime.js` builds are also available.

**Note**: The S3 builds page is provided as a convenience for the community,
but you should not use it for hosting Handlebars in production.

Usage
-----
In general, the syntax of Handlebars.js templates is a superset
Expand Down Expand Up @@ -389,3 +400,4 @@ License
-------
Handlebars.js is released under the MIT license.

[builds-page]: http://builds.handlebarsjs.com.s3.amazonaws.com/index.html
26 changes: 26 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,29 @@ task :bench => "vendor" do

system "node bench/handlebars.js"
end

task :publish do
access_key_id = ENV['S3_ACCESS_KEY_ID']
secret_access_key = ENV['S3_SECRET_ACCESS_KEY']
bucket_name = ENV['S3_BUCKET_NAME']
rev = `git rev-list HEAD -n 1`.to_s.strip
master_rev = `git rev-list origin/master -n 1`.to_s.strip
upload = true if rev == master_rev
upload = upload && access_key_id && secret_access_key && bucket_name
if upload
require 'aws-sdk'
root = File.expand_path(File.dirname(__FILE__)) + '/dist/'
s3 = AWS::S3.new(access_key_id: access_key_id,secret_access_key: secret_access_key)
bucket = s3.buckets[bucket_name]
files = ['handlebars.js', 'handlebars.runtime.js'].map { |file| root + file }
files.each do |file|
basename = Pathname.new(file).basename.sub_ext('')
s3_objs = ["#{basename}-latest.js", "#{basename}-#{rev}.js"].map do |file|
bucket.objects[file]
end
s3_objs.each { |obj| obj.write(Pathname.new(file)) }
end
else
puts "Not uploading any files to S3!"
end
end
Loading

0 comments on commit 265d624

Please sign in to comment.