Skip to content

Instantly share code, notes, and snippets.

@thekid
Last active November 11, 2015 00:41
Show Gist options
  • Select an option

  • Save thekid/13f2040caed3e75e84de to your computer and use it in GitHub Desktop.

Select an option

Save thekid/13f2040caed3e75e84de to your computer and use it in GitHub Desktop.
Experiment with build and deploy
build: zip
zip:
- conf
- lib
- src
- etc
deploy: shell
shell:
- scp $BUILD_TARGET vm-example:/tmp/
- ssh -t vm-example "sudo installapp install -a com.example.svc e -g $ORGANIZATION -n $REPOSITORY -f /tmp/$BUILD_TARGET"
class ZipBuild
def execute(config, vars)
vars['$BUILD_TARGET']= vars['$ORGANIZATION'] + '-' + vars['$REPOSITORY'] + '-' + vars['$VERSION'] + '.zip'
command = 'zip $BUILD_TARGET -R'
config['zip'].each do |source|
command += ' ' + source
end
yield command
end
end
require 'psych'
# Parse command line
organization, repository = ARGV[0].split('/')
version = ARGV[1].match(/v([0-9.]+)/)[1]
vars = {
'$ORGANIZATION' => organization,
'$REPOSITORY' => repository,
'$VERSION' => version
}
# Parse meta infos
config = Psych.load_file('.nessie.yml')
# Execute steps
['build', 'deploy'].each do |step|
load "#{step}-#{config[step]}.rb"
Object.const_get("#{config[step].capitalize}#{step.capitalize}").new.execute(config, vars) do |command|
puts command.gsub(/\$[A-Z_-]+/, vars)
end
end
class ShellDeploy
def execute(config, vars)
config['shell'].each do |command|
yield command
end
end
end
@thekid
Copy link
Author

thekid commented Nov 11, 2015

Execute as follows:

$ (echo "#!/bin/sh" ; ruby1.9.3 compile.rb example/url-shortener v1.0.0) > nessie.sh
$ sh nessie.sh

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