Revup
Revup is a simple deployment utility, for the Sauspiel client versioned_assets, packaged as a rake task.
You tell it which files to deploy and Revup will push it to the server and register the new revision of the versioned_asset.
Install
Revup is packaged as a Ruby gem and can be added to the Gemfile of the versioned_asset project:
gem "revup", "~> 0.1.0"
Usage
To add a deploy task for a versioned_asset, add the following to its Rakefile:
task :build do
# builds the versioned_asset
end
namespace :deploy do
require 'revup/deploy_task'
Revup::DeployTask.new(:desktop => build) do |deploy|
deploy.host = 'remote.server.hostname'
deploy.app_dir = '/path/to/app/root'
deploy.files_root = File.expand_path('../build', __FILE__)
deploy.versioned_asset_name = 'html5-desktop-game-client'
deploy.files = %w{
game_client_desktop.html
sauspiel.desktop-datauri.css
libs.js
sauspiel.desktop.js
}
deploy.remote_setup = 'export PATH=/foo/bin:$PATH APP=sauspiel; eval "$(rbenv init -)"'
end
end
This will add a task called deploy:desktop
. You could also call the task ‘html5-desktop-game-client’, in which case you don’t have to explicitely specify the versioned_asset_name
.
The, optional, remote_setup
setting is a string that will be prepended to each command performed on the remote host.
If you have multiple deploy tasks it can be handy to define shared settings on the class. Eg:
namespace :deploy do
require 'revup/deploy_task'
Revup::DeployTask.host = 'remote.server.hostname'
Revup::DeployTask.remote_setup = 'export PATH=/foo/bin:$PATH APP=sauspiel; eval "$(rbenv init -)"'
Revup::DeployTask.app_dir = '/path/to/app/root'
Revup::DeployTask.files_root = File.expand_path('../build', __FILE__)
Revup::DeployTask.new(:desktop => build) do |deploy|
deploy.versioned_asset_name = 'html5-desktop-game-client'
deploy.files = %w{
game_client_desktop.html
sauspiel.desktop-datauri.css
libs.js
sauspiel.desktop.js
}
end
end
Register versioned_asset with Rails app
Before you can actually deploy a new revision of a versioned_asset, the Rails application will have to know about that versioned_asset.
% APP=sauspiel RAILS_ENV=test bundle exec rails console
Loading test environment (Rails 3.1.3)
irb(main):001:0> VersionedAsset.create(:name => 'html5-desktop-game-client')
(0.1ms) BEGIN
SQL (0.5ms) INSERT INTO `versioned_assets` (`created_at`, `name`, `released_revision_id`, `updated_at`) VALUES ('2012-01-12 14:27:23', 'html5-desktop-game-client', NULL, '2012-01-12 14:27:23')
(0.6ms) COMMIT
=> #<VersionedAsset id: 909168789, name: "html5-desktop-game-client", released_revision_id: nil, created_at: "2012-01-12 14:27:23", updated_at: "2012-01-12 14:27:23">