Class: Samus::Builder
- Inherits:
-
Object
- Object
- Samus::Builder
- Defined in:
- lib/samus/builder.rb
Constant Summary collapse
- RESTORE_FILE =
'.git/samus-restore'.freeze
Class Attribute Summary collapse
-
.build_version ⇒ Object
Returns the value of attribute build_version.
Instance Attribute Summary collapse
-
#build_manifest ⇒ Object
readonly
Returns the value of attribute build_manifest.
Instance Method Summary collapse
- #build(dry_run = false, zip_release = true, outfile = nil, skip_restore = false) ⇒ Object
-
#initialize(build_manifest_file) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(build_manifest_file) ⇒ Builder
Returns a new instance of Builder.
17 18 19 20 21 22 23 |
# File 'lib/samus/builder.rb', line 17 def initialize(build_manifest_file) fdata = File.read(build_manifest_file).gsub('$version', version) @stage = 'build' @build_manifest_file = build_manifest_file @build_manifest = JSON.parse(fdata) @manifest = {} end |
Class Attribute Details
.build_version ⇒ Object
Returns the value of attribute build_version.
12 13 14 |
# File 'lib/samus/builder.rb', line 12 def build_version @build_version end |
Instance Attribute Details
#build_manifest ⇒ Object (readonly)
Returns the value of attribute build_manifest.
15 16 17 |
# File 'lib/samus/builder.rb', line 15 def build_manifest @build_manifest end |
Instance Method Details
#build(dry_run = false, zip_release = true, outfile = nil, skip_restore = false) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/samus/builder.rb', line 25 def build(dry_run = false, zip_release = true, outfile = nil, skip_restore = false) orig_pwd = Dir.pwd manifest = { 'version' => version, 'actions' => [] } build_branch = "samus-release/v#{version}" orig_branch = `git symbolic-ref -q --short HEAD`.chomp if `git diff --shortstat 2> #{devnull} | tail -n1` != '' Samus.error 'Repository is dirty, it is too dangerous to continue.' end system "git checkout -qb #{build_branch} 2>#{devnull}" remove_restore_file Dir.mktmpdir do |build_dir| pwdpath = Pathname.new(Dir.pwd) build_dir = Pathname.new(build_dir).relative_path_from(pwdpath).to_s actions.map do |action| BuildAction.new(dry_run: dry_run, arguments: { '_RESTORE_FILE' => RESTORE_FILE, '_BUILD_DIR' => build_dir, '_BUILD_BRANCH' => build_branch, '_DEVNULL' => devnull, 'VERSION' => version }).load(action) end.each do |action| next if action.skip action.run manifest['actions'] += action.publish if action.publish end unless dry_run Dir.chdir(build_dir) do generate_manifest(manifest) generate_release(orig_pwd, zip_release, outfile) end end end ensure if skip_restore remove_restore_file else restore_git_repo system "git checkout -q #{orig_branch} 2>#{devnull}" system "git branch -qD #{build_branch} 2>#{devnull}" end end |