muflax65ngodyewp.onion/commands/publish.rb

46 lines
1.1 KiB
Ruby
Raw Normal View History

2012-04-12 19:00:22 +02:00
# add list of all sites so that this file does something useful
usage 'publish'
summary 'publish site(s)'
description 'Publishes site(s) to all online targets.'
flag :p, :'pretend', 'pretend to publish'
required :s, :sites, 'sites'
module Nanoc::CLI::Commands
class Publish < ::Nanoc::CLI::CommandRunner
def run
2012-06-09 11:02:19 +02:00
def cmd command
m = method(options[:pretend] ? :puts : :system)
m.call(command) or raise "command failed: '#{command}'"
end
2012-04-12 19:00:22 +02:00
# push changes to github
2013-04-02 23:27:50 +02:00
cmd "git push --all origin"
2012-04-12 19:00:22 +02:00
2012-04-15 22:48:52 +02:00
# regenerate site links
2012-06-09 11:02:19 +02:00
cmd "nanoc references"
2012-04-15 22:48:52 +02:00
2012-04-18 02:11:31 +02:00
# prepare images
2012-06-09 11:02:19 +02:00
cmd "nanoc images"
2012-04-18 02:11:31 +02:00
2012-04-12 19:00:22 +02:00
sites_arg(options[:sites]).each do |site|
puts "publishing site: #{site}"
# clean unneeded files
2012-06-09 11:02:19 +02:00
cmd "nanoc prune -s #{site} --yes"
2012-04-15 22:48:52 +02:00
2012-04-12 19:00:22 +02:00
# compile site to ensure a usable state
2012-06-09 11:02:19 +02:00
cmd "nanoc compile -s #{site}"
2012-04-12 19:00:22 +02:00
# compress files
2012-06-09 11:02:19 +02:00
cmd "nanoc compress -s #{site}"
2012-04-12 19:00:22 +02:00
# deploy files
2012-06-09 11:02:19 +02:00
cmd "nanoc deploy -t default -s #{site}"
2012-04-12 19:00:22 +02:00
end
end
end
end
runner Nanoc::CLI::Commands::Publish