Last active
November 11, 2015 00:41
-
-
Save thekid/13f2040caed3e75e84de to your computer and use it in GitHub Desktop.
Experiment with build and deploy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ShellDeploy | |
| def execute(config, vars) | |
| config['shell'].each do |command| | |
| yield command | |
| end | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Execute as follows: