Sha256: 52be9eca8de183e6f34a9f6a7bfa40c0d4dd5e9d3e48e6359a8506bec3d4ecd1
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
module Soaring class Packager def initialize(options) @options = options end def package validate_project if not @options[:ignore_git_checks] build_output_location = generate_build_output_location(@options[:project_root]) update_project_commit_hash `mkdir -p #{@options[:project_root]}/build` `cd #{@options[:project_root]}; zip -r #{build_output_location} * .ebextensions --exclude=build/* --exclude=config/environment.yml` puts "Build packaged at #{build_output_location}" end private def validate_project if not is_git_repo_up_to_date? puts "Local git repo is dirty and should not be packaged" exit 1 end puts 'Local git repo up to date.' if @options[:verbose] end def generate_build_output_location(project_folder) service_name = File.split(project_folder)[-1] timestamp = Time.now.strftime("%F-%H%M%S") "#{project_folder}/build/build_#{service_name}_#{get_short_commit_hash}_#{timestamp}.zip" end def update_project_commit_hash response, exit_status = Executor::execute("cd #{@options[:project_root]}; git rev-parse HEAD > commit-hash") if not exit_status.success? puts 'Failed to package, unable to get commit hash from local git repository' exit 1 end end def is_git_repo_up_to_date? response, exit_status = Executor::execute("cd #{@options[:project_root]}; git status --porcelain") return true if ('' == response) and (exit_status.success?) false end def get_short_commit_hash response, exit_status = Executor::execute("cd #{@options[:project_root]}; git rev-parse --short HEAD") if not exit_status.success? puts 'Failed to package, unable to get short commit hash from local git repository' exit 1 end response.chomp end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
soaring-0.1.13 | lib/soaring/packager.rb |
soaring-0.1.12 | lib/soaring/packager.rb |