Class: Yolo::Tasks::Ios::Release
- Defined in:
- lib/yolo/tasks/ios/release.rb
Overview
Executes all release related tasks
Instance Attribute Summary collapse
-
#deployment ⇒ Object
The deployment class to use when deploying.
-
#github_repo ⇒ Object
A Github repo to release to.
-
#mail_to ⇒ Array
Returns the release class’s mail_to attribute, if no attribute is set then check for the config env var.
-
#options ⇒ Object
A Hash of additional options.
Instance Method Summary collapse
-
#app_path ⇒ String
Uses Xcode to find the full path to generated app file.
-
#bundle_path ⇒ String
The full path used when saving files for the build, the path is created using the bundle_directory, folder_name and version methods combined into a single path.
-
#configuration ⇒ String
Returns the release class’s configuration attribute, if no attribute is set then check for the config env var.
-
#current_branch ⇒ String
The current git branch.
-
#define ⇒ Object
Defines the rake tasks available to the class.
-
#deploy(ipa_path) ⇒ Object
Deploys the ipa using the defined deployment strategy, the deployment class is created using the deployment variable as the class name so it is crucial the correct class is in the project.
-
#deploy_class_from_string(string) ⇒ Object
Initlizes an object from a deployment string.
-
#dsym_path ⇒ String
The path to the applications dSYM folder, the dSYM path is calculated by manipulating the app_path.
-
#folder_name ⇒ String
The folder name to use for the build bundle directory, the name is created using the relevant scheme and build configuration.
-
#info_plist_path ⇒ String
The path to the info-plist file, the method persumes that the command is being called from the directory which contains the plist.
-
#initialize ⇒ Release
constructor
Initializes the class with default settings.
-
#release_to_github(bundle_path) ⇒ Object
Release the ipa using the github releases API, the ipa will be zipped and uploaded as well as the release notes used as the release body and version for the release title.
-
#scheme ⇒ String
Returns the release class’s scheme attribute, if no attribute is set then check for the scheme env var.
-
#send_notification(url, password) ⇒ Object
Sends a notificaiton email from a deployment.
-
#version ⇒ String
The version string of the built application if the version number can not be retrieved from Xcode the current date time will be used.
Methods inherited from BaseTask
Constructor Details
#initialize ⇒ Release
Initializes the class with default settings
25 26 27 28 29 30 31 32 33 |
# File 'lib/yolo/tasks/ios/release.rb', line 25 def initialize self.sdk = "iphoneos" unless sdk self.deployment = :OTA @error_formatter = Yolo::Formatters::ErrorFormatter.new @emailer = Yolo::Notify::Ios::OTAEmail.new @xcode = Yolo::Tools::Ios::Xcode.new @bundle_directory = Yolo::Config::Settings.instance.bundle_directory super end |
Instance Attribute Details
#deployment ⇒ Object
The deployment class to use when deploying
16 17 18 |
# File 'lib/yolo/tasks/ios/release.rb', line 16 def deployment @deployment end |
#github_repo ⇒ Object
A Github repo to release to
20 21 22 |
# File 'lib/yolo/tasks/ios/release.rb', line 20 def github_repo @github_repo end |
#mail_to ⇒ Array
Returns the release class’s mail_to attribute, if no attribute is set then check for the config env var
14 15 16 |
# File 'lib/yolo/tasks/ios/release.rb', line 14 def mail_to @mail_to end |
#options ⇒ Object
A Hash of additional options
18 19 20 |
# File 'lib/yolo/tasks/ios/release.rb', line 18 def @options end |
Instance Method Details
#app_path ⇒ String
Uses Xcode to find the full path to generated app file
85 86 87 88 89 90 91 92 |
# File 'lib/yolo/tasks/ios/release.rb', line 85 def app_path files = [] Find.find(@xcode.build_path) do |path| files << path if path =~ /\/Build\/Products\/.*-iphoneos\/#{name}\.app$/ end path = files.sort_by { |filename| File.mtime(filename)}.last # get the latest path end |
#bundle_path ⇒ String
The full path used when saving files for the build, the path is created using the bundle_directory, folder_name and version methods combined into a single path
113 114 115 |
# File 'lib/yolo/tasks/ios/release.rb', line 113 def bundle_path "#{@bundle_directory}/#{folder_name}/#{version}" end |
#configuration ⇒ String
Returns the release class’s configuration attribute, if no attribute is set then check for the config env var
71 72 73 74 75 76 77 78 79 |
# File 'lib/yolo/tasks/ios/release.rb', line 71 def configuration config = @configuration if !config config = ENV['YOLO_RELEASE_CONFIG'] end return config end |
#current_branch ⇒ String
The current git branch
216 217 218 219 220 221 222 |
# File 'lib/yolo/tasks/ios/release.rb', line 216 def current_branch git = Yolo::Tools::Git.new branch = git.current_branch if git.current_branch != "(no branch)" return "(#{branch})" end end |
#define ⇒ Object
Defines the rake tasks available to the class
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/yolo/tasks/ios/release.rb', line 241 def define super namespace :yolo do namespace :release do desc "Builds and deploys a release ipa of specified scheme." task :ipa do xcodebuild :build Yolo::Tools::Ios::IPA.generate(app_path,dsym_path,bundle_path) do |ipa| deploy(ipa) if ipa and self.deployment release_to_github(bundle_path) if ipa and self.github_repo end end desc "Builds and packages a release build for the newest git tag" task :tag do git = Yolo::Tools::Git.new if git.has_new_tag(name) Rake::Task["yolo:release:ipa"].invoke end end desc "Builds and packages a release build for the newest commit" task :commit do git = Yolo::Tools::Git.new if git.has_new_commit(name) Rake::Task["yolo:release:ipa"].invoke end end desc "Generates a release notes file" task :notes do Yolo::Tools::Ios::ReleaseNotes.generate(info_plist_path) end end end end |
#deploy(ipa_path) ⇒ Object
Deploys the ipa using the defined deployment strategy, the deployment class is created using the deployment variable as the class name so it is crucial the correct class is in the project.
Once deploy is succesful this method will also trigger an email notification using the OTAEmail class
169 170 171 172 173 174 175 176 |
# File 'lib/yolo/tasks/ios/release.rb', line 169 def deploy(ipa_path) klass = deploy_class_from_string "#{self.deployment.to_s}" if klass klass.deploy(ipa_path, ) do |url, password| send_notification(url, password) end end end |
#deploy_class_from_string(string) ⇒ Object
Initlizes an object from a deployment string
229 230 231 232 233 234 235 236 |
# File 'lib/yolo/tasks/ios/release.rb', line 229 def deploy_class_from_string(string) klass = Object.const_get("Yolo").const_get("Deployment").const_get("#{self.deployment.to_s}").new unless klass @error_formatter.deployment_class_error(self.deployment.to_s) return end klass end |
#dsym_path ⇒ String
The path to the applications dSYM folder, the dSYM path is calculated by manipulating the app_path
99 100 101 102 103 104 105 |
# File 'lib/yolo/tasks/ios/release.rb', line 99 def dsym_path paths = app_path.split("/") app_file = paths.last paths.pop path = paths.join("/") "#{path}/#{app_file}.dSYM" end |
#folder_name ⇒ String
The folder name to use for the build bundle directory, the name is created using the relevant scheme and build configuration
122 123 124 125 126 |
# File 'lib/yolo/tasks/ios/release.rb', line 122 def folder_name folder_name = name folder_name = "#{name}-#{self.configuration}" if self.configuration folder_name end |
#info_plist_path ⇒ String
The path to the info-plist file, the method persumes that the command is being called from the directory which contains the plist
133 134 135 136 137 138 139 |
# File 'lib/yolo/tasks/ios/release.rb', line 133 def info_plist_path plist_path = "" Find.find(Dir.pwd) do |path| plist_path = path if path =~ /#{name}-Info.plist$/ end plist_path end |
#release_to_github(bundle_path) ⇒ Object
Release the ipa using the github releases API, the ipa will be zipped and uploaded as well as the release notes used as the release body and version for the release title
185 186 187 188 189 190 191 192 |
# File 'lib/yolo/tasks/ios/release.rb', line 185 def release_to_github(bundle_path) if self.github_repo github = Yolo::Tools::Github.new notes = Yolo::Tools::Ios::ReleaseNotes.html github.repo = self.github_repo github.release(bundle_path, version, notes) end end |
#scheme ⇒ String
Returns the release class’s scheme attribute, if no attribute is set then check for the scheme env var
56 57 58 59 60 61 62 63 64 |
# File 'lib/yolo/tasks/ios/release.rb', line 56 def scheme scheme = @scheme if !scheme scheme = ENV['YOLO_RELEASE_SCHEME'] end return scheme end |
#send_notification(url, password) ⇒ Object
Sends a notificaiton email from a deployment
199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/yolo/tasks/ios/release.rb', line 199 def send_notification(url, password) if url = { :to => self.mail_to, :ota_url => url, :subject => "New #{name} build: #{version} #{current_branch}", :title => name } [:ota_password] = password if password @emailer.send() end end |
#version ⇒ String
The version string of the built application if the version number can not be retrieved from Xcode the current date time will be used
147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/yolo/tasks/ios/release.rb', line 147 def version @xcode.info_plist_path = info_plist_path folder = "" folder << @xcode.version_number if @xcode.version_number folder << "-#{@xcode.build_number}" if @xcode.build_number if folder.length == 0 time = Time.now folder = "#{time.day}-#{time.month}-#{time.year}-#{time.hour}-#{time.min}-#{time.sec}" end folder end |