Class: Egads::Build

Inherits:
Group
  • Object
show all
Includes:
BuildHelpers, LocalHelpers, Thor::Actions
Defined in:
lib/egads/command/build.rb

Defined Under Namespace

Modules: BuildHelpers

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BuildHelpers

#can_build?, #error, #patch_path, #sha_is_checked_out?, #should_build?, #working_directory_is_clean?

Methods included from LocalHelpers

#sha, #short_sha, #tarball

Methods inherited from Group

exit_on_failure?

Instance Attribute Details

#build_shaObject

Returns the value of attribute build_sha.



11
12
13
# File 'lib/egads/command/build.rb', line 11

def build_sha
  @build_sha
end

Instance Method Details

#check_buildObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/egads/command/build.rb', line 13

def check_build
  say_status :rev, "#{rev} parsed to #{sha}"

  unless should_build?
    say_status :done, "tarball for #{sha} already exists. Pass --force to rebuild."
    exit 0
  end

  exit 1 unless can_build?
  say_status :build, "Making tarball for #{sha}", :yellow
end

#commit_extra_pathsObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/egads/command/build.rb', line 33

def commit_extra_paths
  # Double-check that SHA hasn't changed since we started building
  exit 1 unless sha_is_checked_out?

  extra_paths = ["REVISION"]
  extra_paths += Config.build_extra_paths
  run_with_code("git add -f #{extra_paths * ' '} && git commit --no-verify -m '[egads seed] [ci skip]'")
  # Get the build SHA
  self.build_sha = run_with_code("git rev-parse --verify HEAD").strip
  run_with_code "git reset #{sha}" # Reset to original SHA

end

#make_tarballObject



46
47
48
# File 'lib/egads/command/build.rb', line 46

def make_tarball
  run_with_code "git archive #{build_sha} --output #{tarball.local_tar_path}"
end

#run_after_build_hooksObject



50
51
52
# File 'lib/egads/command/build.rb', line 50

def run_after_build_hooks
  run_hooks_for(:build, :after)
end

#run_before_build_hooksObject



25
26
27
# File 'lib/egads/command/build.rb', line 25

def run_before_build_hooks
  run_hooks_for(:build, :before)
end

#uploadObject



54
55
56
# File 'lib/egads/command/build.rb', line 54

def upload
  invoke(Egads::Upload, [sha], force: options[:force]) unless options['no-upload']
end

#write_revision_fileObject



29
30
31
# File 'lib/egads/command/build.rb', line 29

def write_revision_file
  File.open('REVISION', 'w') {|f| f << sha + "\n" }
end