class Admiral::Tasks::Deploy

Constants

DESCRIPTION
NAME
USAGE

Public Instance Methods

build() click to toggle source
# File lib/admiral-meteor/tasks.rb, line 40
def build
  Dir.mktmpdir do |tmpdir|
    build_dir = "#{tmpdir}/admiral-build"
    repo = options[:repo] || Dir.pwd

    if options[:tag]
      git = Git.open(repo)
      puts "[admiral] Tagging release #{options[:tag]}."
      git.add_tag(options[:tag], m: 'tagging release')
    end

    puts "[admiral] Creating new meteor build."
    _git = Git.clone(repo, "#{tmpdir}/admiral-checkout")
    branch = _git.branches[options[:branch]]
    raise "Branch doesn't exist" unless branch
    branch.checkout

    _git.chdir do
      `meteor build #{build_dir} --directory --architecture=#{options[:architecture]}`
    end

    `cp -a ./deploy #{build_dir}/bundle`
    `mv #{build_dir}/bundle/main.js #{build_dir}/bundle/server.js`
    `tar -C #{build_dir}/bundle/ -zcf ./#{options[:name]}.tar.gz .`
  end
end
push() click to toggle source
# File lib/admiral-meteor/tasks.rb, line 75
def push
  invoke :build

  puts "[admiral] Pushing meteor build to S3."
  s3 = AWS::S3.new
  name = "#{options[:name]}.tar.gz"
  build = s3.buckets[options[:bucket]].objects[name]
  build.write(:file => "./#{name}")
end