Skip to content

Instantly share code, notes, and snippets.

@dmalikov
Created December 7, 2012 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmalikov/4237146 to your computer and use it in GitHub Desktop.
Save dmalikov/4237146 to your computer and use it in GitHub Desktop.
deploy liblastfm haddocks to budueba.com
# Deploying haddocks
#
# cap deploy:haddocks
load 'deploy'
ssh_options[:forward_agent] = true
after "deploy:create_symlink", "deploy:cleanup"
# initializen
default_run_options[:pty] = true
set :use_sudo, false
set :keep_releases, 10
set :deploy_via, :copy
set :application, "liblastfm"
set :deploy_to, "/var/www/budueba.com/data"
set :current_path, "/var/www/budueba.com/htdocs"
role :jws, "jws"
namespace :deploy do
desc "Deploy haddock documentation"
task :haddock do
arch_fn = "haddock.tar.gz"
arch_path = File.join( Dir.pwd(), arch_fn )
# pack haddocks
system "cabal-dev haddock --hyperlink-source"
system "tar cjf #{arch_path} -C dist/doc/html/ liblastfm"
# upload archive
run "mkdir -p #{release_path}"
top.upload arch_path, "#{release_path}/", :via => :scp, :recursive => true
# unpack archive
run "rm -rf liblastfm"
run "tar --extract --file #{release_path}/#{arch_fn} --directory=#{release_path} "
run "rm -v #{release_path}/#{arch_fn}"
create_symlink
# remove archive locally
system "rm -v #{arch_path}"
end
end
@dmalikov
Copy link
Author

dmalikov commented Dec 7, 2012

$> cap deploy:haddock
  * executing `deploy:haddock'
Running Haddock for liblastfm-0.0.4.0...
Running hscolour for liblastfm-0.0.4.0...
Preprocessing library liblastfm-0.0.4.0...
Preprocessing test suite 'json-no-authentication' for liblastfm-0.0.4.0...
Preprocessing library liblastfm-0.0.4.0...
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: rts-1.0, random-1.0.1.1
Haddock coverage:
Warning: Network.Lastfm.Internal: Instances of type and data families are not yet supported. Instances of the following families will be filtered out:
  Response
  59% ( 10 / 17) in 'Network.Lastfm.Internal'
 100% (  7 /  7) in 'Network.Lastfm.Response'
  60% ( 46 / 77) in 'Network.Lastfm.Request'
 100% (  6 /  6) in 'Network.Lastfm.Authentication'
  67% ( 10 / 15) in 'Network.Lastfm.Album'
  62% ( 18 / 29) in 'Network.Lastfm.Artist'
 100% (  7 /  7) in 'Network.Lastfm.Chart'
 100% (  7 /  7) in 'Network.Lastfm.Event'
 100% ( 12 / 12) in 'Network.Lastfm.Geo'
 100% ( 10 / 10) in 'Network.Lastfm.Tag'
   0% (  0 /  2) in 'Network.Lastfm.Tasteometer'
  50% (  1 /  2) in 'Network.Lastfm.User'
Warning: liblastfm-0.0.4.0:Network.Lastfm: Could not find documentation for exported module: L
  67% (  2 /  3) in 'Network.Lastfm'
Documentation created: dist/doc/html/liblastfm/index.html
Preprocessing test suite 'json-no-authentication' for liblastfm-0.0.4.0...
  * executing "mkdir -p /var/www/budueba.com/data/releases/20121207224404"
    servers: ["jws"]
    [jws] executing command
    command finished in 218ms
    servers: ["jws"]
 ** scp upload /home/dmalikov/projects/liblastfm/haddock.tar.gz -> /var/www/budueba.com/data/releases/20121207224404/
    [jws] /home/dmalikov/projects/liblastfm/haddock.tar.gz
  * scp upload complete
  * executing "rm -rf liblastfm"
    servers: ["jws"]
    [jws] executing command
    command finished in 52ms
  * executing "tar --extract --file /var/www/budueba.com/data/releases/20121207224404/haddock.tar.gz --directory=/var/www/budueba.com/data/releases/20121207224404"
    servers: ["jws"]
    [jws] executing command
    command finished in 365ms
  * executing "rm -v /var/www/budueba.com/data/releases/20121207224404/haddock.tar.gz"
    servers: ["jws"]
    [jws] executing command
 ** [out :: jws] removed `/var/www/budueba.com/data/releases/20121207224404/haddock.tar.gz'
    command finished in 30ms
  * executing `deploy:create_symlink'
  * executing "rm -f /var/www/budueba.com/htdocs && ln -s /var/www/budueba.com/data/releases/20121207224404 /var/www/budueba.com/htdocs"
    servers: ["jws"]
    [jws] executing command
    command finished in 36ms
    triggering after callbacks for `deploy:create_symlink'
  * executing `deploy:cleanup'
  * executing "ls -xt /var/www/budueba.com/data/releases"
    servers: ["jws"]
    [jws] executing command
    command finished in 29ms
*** no old releases to clean up
removed ‘/home/dmalikov/projects/liblastfm/haddock.tar.gz’

@dmalikov
Copy link
Author

dmalikov commented Dec 7, 2012

/var/www/budueba.com/
├── data
│   └── releases
│       ├── 20121207222946
│       ├── 20121207223134
│       ├── 20121207223504
│       ├── 20121207223714
│       ├── 20121207223736
│       ├── 20121207223854
│       ├── 20121207224011
│       ├── 20121207224124
│       └── 20121207224404
└── htdocs -> /var/www/budueba.com/data/releases/20121207224404

@dmalikov
Copy link
Author

dmalikov commented Dec 7, 2012

How to rollback

$> cap deploy:rollback
  * executing `deploy:rollback'
  * executing `deploy:rollback:revision'
  * executing "ls -x /var/www/budueba.com/data/releases"
    servers: ["jws"]
    [jws] executing command
    command finished in 31ms
  * executing "rm /var/www/budueba.com/htdocs; ln -s /var/www/budueba.com/data/releases/20121207224124 /var/www/budueba.com/htdocs"
    servers: ["jws"]
    [jws] executing command
    command finished in 35ms
  * executing `deploy:restart'
  * executing `deploy:rollback:cleanup'
  * executing "if [ `readlink /var/www/budueba.com/htdocs` != /var/www/budueba.com/data/releases/20121207224404 ]; then rm -rf /var/www/budueba.com/data/releases/20121207224404; fi"
    servers: ["jws"]
    [jws] executing command
    command finished in 53ms

@supki
Copy link

supki commented Dec 7, 2012

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment