Class: HomebrewAutomation::Workflow
- Inherits:
-
Object
- Object
- HomebrewAutomation::Workflow
- Defined in:
- lib/homebrew_automation/workflow.rb
Overview
Imperative glue code.
Each method in this class probably makes sense to be exposed as a CLI command.
Instance Method Summary collapse
-
#build_and_upload_bottle!(sdist, tap, git, formula_name, bversion, logger, mac_os: MacOS, bottle: Bottle, keep_tap_repo: false, keep_homebrew_tmp: false) ⇒ Bottle
Build and upload a bottle.
-
#gather_and_publish_bottles!(sdist, tap, formula_name, bversion, logger) ⇒ NilClass
Gather and publish bottles.
Instance Method Details
#build_and_upload_bottle!(sdist, tap, git, formula_name, bversion, logger, mac_os: MacOS, bottle: Bottle, keep_tap_repo: false, keep_homebrew_tmp: false) ⇒ Bottle
Build and upload a bottle.
The built Bottle tarball gets uploaded to Bintray.
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/homebrew_automation/workflow.rb', line 27 def build_and_upload_bottle!( sdist, tap, git, formula_name, bversion, logger, mac_os: MacOS, bottle: Bottle, keep_tap_repo: false, keep_homebrew_tmp: false) logger.info!( "Hello, this is HomebrewAutomation! I will now build your Formula and upload the " \ "bottles to Bintray.") os_name = mac_os.identify_version! logger.info!("First let's clone your Tap repo to see the Formula.") git.with_clone!(tap.url, tap.repo, keep_dir: keep_tap_repo) do |cloned_dir| tap.on_formula! formula_name do |formula| formula.put_sdist(sdist.url, sdist.sha256) end git.commit_am! "Throwaway commit; just for building bottles" logger.info!( "I've updated the Formula file in our local Tap clone, and we're ready "\ "to start building the Bottle. This could take a long time if your Formula "\ "is slow to compile.") bot = bottle.new( 'homebrew-automation/tmp-tap', cloned_dir, formula_name, os_name, keep_tmp: keep_homebrew_tmp) bot.build! do |filename, contents| # Bintray auto-creates Versions on file-upload. # Re-creating an existing Version results in a 409. #bversion.create! logger.info!("Bottle built! Let me now upload the Bottle tarball to Bintray.") begin bversion.upload_file!(filename, contents) rescue Bintray::Version::FileAlreadyExists logger.info!("A file with the same name as the one we're uploading already exits on Bintray.") end end bot end logger.info!("All done!") rescue HomebrewAutomation::Bottle::Error => e logger.error!([ "Something went wrong in a Bottle: " + e., "Original JSON:", e.original, "Backtrace:", e.backtrace.join("\n") ].join("\n")) rescue HomebrewAutomation::Brew::OlderVersionAlreadyInstalled => e logger.error!([ "An older version of the Formula is already installed on your system. " \ "Please either manually uninstall or upgrade it, then try again.", e.to_s, "Caused by: #{e.cause}", (e.cause ? e.cause.backtrace.join("\n") : '') ].join("\n")) rescue HomebrewAutomation::Brew::Error => e logger.error!( "Something went wrong in this Homebrew command: " + e. + "\n" + e.backtrace.join("\n")) rescue HomebrewAutomation::Git::Error => e logger.error!( "Something went wrong in this Git command: " + e. + "\n" + e.backtrace.join("\n")) end |
#gather_and_publish_bottles!(sdist, tap, formula_name, bversion, logger) ⇒ NilClass
Gather and publish bottles.
Look around on Bintray to see what Bottles we’ve already built and uploaded (as such “gathering” the bottles), then push new commits into the #tap repository to make an existing Formula aware of the Bottles we’re gathered (as such “publishing” the bottles).
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/homebrew_automation/workflow.rb', line 111 def gather_and_publish_bottles!(sdist, tap, formula_name, bversion, logger) logger.info!( "Hello, this is HomebrewAutomation! I will browse through your Bintray to " \ "see if there may be Bottles built earlier for your Formula, and update your " \ "Tap to refer to them.") logger.info!( "I will also update the source tarball of your Formula in your Tap, " \ "effectively releasing a new version of your Formula.") git.with_clone!(tap.url, tap.repo) do tap.on_formula! formula_name do |formula| logger.info!("Let's see if any files on your Bintray look like Bottles.") bottles = bversion.gather_bottles bottles.reduce( formula. put_sdist(sdist.url, sdist.sha256). rm_all_bottles ) do |f, (os, checksum)| f.put_bottle(os, checksum) end end git.config! git.commit_am! "Add bottles for #{formula_name}@#{bversion.version_name}" logger.info!("I've refered to the Bottles I found in this new commit. Let's push to your Tap!") git.push! end logger.info!("All done!") end |