revup 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +81 -0
- data/lib/revup/deploy_task.rb +15 -12
- data/lib/revup/version.rb +1 -1
- metadata +46 -69
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Revup
|
2
|
+
|
3
|
+
Revup is a simple deployment utility, for the Sauspiel client versioned_assets, packaged as a rake task.
|
4
|
+
|
5
|
+
You tell it which files to deploy and Revup will push it to the server and register the new revision of the versioned_asset.
|
6
|
+
|
7
|
+
|
8
|
+
## Install
|
9
|
+
|
10
|
+
Revup is packaged as a Ruby gem and can be added to the Gemfile of the versioned_asset project:
|
11
|
+
|
12
|
+
```Ruby
|
13
|
+
gem "revup", "~> 0.1.0"
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
To add a deploy task for a versioned_asset, add the following to its Rakefile:
|
19
|
+
|
20
|
+
```Ruby
|
21
|
+
task :build do
|
22
|
+
# builds the versioned_asset
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :deploy do
|
26
|
+
require 'revup/deploy_task'
|
27
|
+
|
28
|
+
Revup::DeployTask.new(:desktop => build) do |deploy|
|
29
|
+
deploy.host = 'remote.server.hostname'
|
30
|
+
deploy.app_dir = '/path/to/app/root'
|
31
|
+
deploy.files_root = File.expand_path('../build', __FILE__)
|
32
|
+
deploy.versioned_asset_name = 'html5-desktop-game-client'
|
33
|
+
deploy.files = %w{
|
34
|
+
game_client_desktop.html
|
35
|
+
sauspiel.desktop-datauri.css
|
36
|
+
libs.js
|
37
|
+
sauspiel.desktop.js
|
38
|
+
}
|
39
|
+
deploy.remote_setup = 'export PATH=/foo/bin:$PATH APP=sauspiel; eval "$(rbenv init -)"'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
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`.
|
45
|
+
|
46
|
+
The, optional, `remote_setup` setting is a string that will be prepended to each command performed on the remote host.
|
47
|
+
|
48
|
+
If you have multiple deploy tasks it can be handy to define shared settings on the class. Eg:
|
49
|
+
|
50
|
+
```Ruby
|
51
|
+
namespace :deploy do
|
52
|
+
require 'revup/deploy_task'
|
53
|
+
|
54
|
+
Revup::DeployTask.host = 'remote.server.hostname'
|
55
|
+
Revup::DeployTask.remote_setup = 'export PATH=/foo/bin:$PATH APP=sauspiel; eval "$(rbenv init -)"'
|
56
|
+
Revup::DeployTask.app_dir = '/path/to/app/root'
|
57
|
+
Revup::DeployTask.files_root = File.expand_path('../build', __FILE__)
|
58
|
+
|
59
|
+
Revup::DeployTask.new(:desktop => build) do |deploy|
|
60
|
+
deploy.versioned_asset_name = 'html5-desktop-game-client'
|
61
|
+
deploy.files = %w{
|
62
|
+
game_client_desktop.html
|
63
|
+
sauspiel.desktop-datauri.css
|
64
|
+
libs.js
|
65
|
+
sauspiel.desktop.js
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
## Register versioned_asset with Rails app
|
72
|
+
|
73
|
+
Before you can actually deploy a new revision of a versioned_asset, the Rails application will have to know about that versioned_asset.
|
74
|
+
|
75
|
+
% APP=sauspiel RAILS_ENV=test bundle exec rails console
|
76
|
+
Loading test environment (Rails 3.1.3)
|
77
|
+
irb(main):001:0> VersionedAsset.create(:name => 'html5-desktop-game-client')
|
78
|
+
(0.1ms) BEGIN
|
79
|
+
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')
|
80
|
+
(0.6ms) COMMIT
|
81
|
+
=> #<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">
|
data/lib/revup/deploy_task.rb
CHANGED
@@ -7,7 +7,7 @@ require 'revup/version'
|
|
7
7
|
|
8
8
|
module Revup
|
9
9
|
class DeployTask < Rake::TaskLib
|
10
|
-
DEFAULT_TO_CLASS_ATTRS = [:host, :app_dir, :remote_setup, :files_root, :logger, :local_tmp_dir, :remote_tmp_dir]
|
10
|
+
DEFAULT_TO_CLASS_ATTRS = [:host, :user, :app_dir, :remote_setup, :files_root, :logger, :local_tmp_dir, :remote_tmp_dir]
|
11
11
|
class << self
|
12
12
|
attr_accessor *DEFAULT_TO_CLASS_ATTRS
|
13
13
|
end
|
@@ -18,14 +18,16 @@ module Revup
|
|
18
18
|
logger.level = Logger::INFO
|
19
19
|
logger.progname = "revup (#{VERSION})"
|
20
20
|
|
21
|
-
attr_accessor :
|
21
|
+
attr_accessor :versioned_asset_name
|
22
22
|
|
23
|
-
attr_accessor :
|
23
|
+
attr_accessor :versioned_asset_name_and_prerequisites
|
24
24
|
|
25
25
|
attr_accessor :files_root, :files
|
26
26
|
|
27
27
|
attr_accessor :host
|
28
28
|
|
29
|
+
attr_accessor :user
|
30
|
+
|
29
31
|
attr_accessor :app_dir
|
30
32
|
|
31
33
|
attr_accessor :revision
|
@@ -36,14 +38,14 @@ module Revup
|
|
36
38
|
|
37
39
|
attr_accessor :logger
|
38
40
|
|
39
|
-
def initialize(
|
41
|
+
def initialize(versioned_asset_name_and_prerequisites)
|
40
42
|
DEFAULT_TO_CLASS_ATTRS.each do |attr|
|
41
43
|
send("#{attr}=", self.class.send(attr))
|
42
44
|
end
|
43
45
|
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
46
|
+
@versioned_asset_name_and_prerequisites = versioned_asset_name_and_prerequisites
|
47
|
+
@versioned_asset_name = @versioned_asset_name_and_prerequisites.is_a?(Hash) ?
|
48
|
+
@versioned_asset_name_and_prerequisites.keys.first : @versioned_asset_name_and_prerequisites
|
47
49
|
|
48
50
|
yield self if block_given?
|
49
51
|
define
|
@@ -57,7 +59,7 @@ module Revup
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def archive_basename
|
60
|
-
"#{@
|
62
|
+
"#{@versioned_asset_name}-#{@revision}"
|
61
63
|
end
|
62
64
|
|
63
65
|
def local_archive_path
|
@@ -75,8 +77,8 @@ module Revup
|
|
75
77
|
# Actual task definition
|
76
78
|
|
77
79
|
def define
|
78
|
-
desc "Deploy build of the `#{@
|
79
|
-
task(@
|
80
|
+
desc "Deploy build of the `#{@versioned_asset_name}' versioned_asset"
|
81
|
+
task(@versioned_asset_name_and_prerequisites) do
|
80
82
|
deploy
|
81
83
|
end
|
82
84
|
end
|
@@ -85,6 +87,7 @@ module Revup
|
|
85
87
|
validate files_root, "Please specify the location of the root of the files that should be deployed."
|
86
88
|
validate files, "Please specify a list of files that should be deployed."
|
87
89
|
validate host, "Please specify the host of the machine to deploy to."
|
90
|
+
validate user, "Please specify the user of the machine to deploy to."
|
88
91
|
validate app_dir, "Please specify the path to the application."
|
89
92
|
validate revision, "Please specify the Git revision hash."
|
90
93
|
|
@@ -102,7 +105,7 @@ module Revup
|
|
102
105
|
end
|
103
106
|
|
104
107
|
def upload_and_register
|
105
|
-
Net::SSH.start(@host,
|
108
|
+
Net::SSH.start(@host, @user) do |connection|
|
106
109
|
@ssh = connection
|
107
110
|
|
108
111
|
ssh "mkdir -p '#{remote_archive_dir}'"
|
@@ -112,7 +115,7 @@ module Revup
|
|
112
115
|
# Unpack archive
|
113
116
|
ssh "tar -C '#{remote_archive_dir}' -zxf '#{remote_archive_path}'"
|
114
117
|
# Register revision
|
115
|
-
ssh "cd '#{@app_dir}' && bundle exec ./script/
|
118
|
+
ssh "cd '#{@app_dir}' && bundle exec ./script/register_versioned_asset_revision '#{remote_archive_dir}' '#{versioned_asset_name}' '#{revision}'"
|
116
119
|
|
117
120
|
cleanup!
|
118
121
|
end
|
data/lib/revup/version.rb
CHANGED
metadata
CHANGED
@@ -1,107 +1,84 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: revup
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Eloy Duran
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-01-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: net-ssh
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
16
|
+
requirement: &70336829881540 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 2
|
29
|
-
- 3
|
30
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
31
21
|
version: 2.3.0
|
32
22
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: net-scp
|
36
23
|
prerelease: false
|
37
|
-
|
38
|
-
|
24
|
+
version_requirements: *70336829881540
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: net-scp
|
27
|
+
requirement: &70336829881020 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
39
30
|
- - ~>
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 1
|
43
|
-
- 0
|
44
|
-
- 4
|
31
|
+
- !ruby/object:Gem::Version
|
45
32
|
version: 1.0.4
|
46
33
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: rspec
|
50
34
|
prerelease: false
|
51
|
-
|
52
|
-
|
35
|
+
version_requirements: *70336829881020
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70336829880220 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
53
41
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 2
|
57
|
-
- 8
|
58
|
-
- 0
|
42
|
+
- !ruby/object:Gem::Version
|
59
43
|
version: 2.8.0
|
60
44
|
type: :development
|
61
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70336829880220
|
62
47
|
description:
|
63
|
-
email:
|
48
|
+
email:
|
64
49
|
- eloy@fngtps.com
|
65
50
|
- martin@sauspiel.de
|
66
51
|
executables: []
|
67
|
-
|
68
52
|
extensions: []
|
69
|
-
|
70
53
|
extra_rdoc_files: []
|
71
|
-
|
72
|
-
files:
|
54
|
+
files:
|
73
55
|
- lib/revup/deploy_task.rb
|
74
56
|
- lib/revup/version.rb
|
75
57
|
- LICENSE
|
76
|
-
|
58
|
+
- README.md
|
77
59
|
homepage:
|
78
|
-
licenses:
|
60
|
+
licenses:
|
79
61
|
- MIT
|
80
62
|
post_install_message:
|
81
63
|
rdoc_options: []
|
82
|
-
|
83
|
-
require_paths:
|
64
|
+
require_paths:
|
84
65
|
- lib
|
85
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
- 0
|
98
|
-
version: "0"
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
99
78
|
requirements: []
|
100
|
-
|
101
79
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 1.8.11
|
103
81
|
signing_key:
|
104
82
|
specification_version: 3
|
105
83
|
summary: A simple deploy tool, packaged as a rake task. Currently targeted for sauspiel.de
|
106
84
|
test_files: []
|
107
|
-
|