Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom ports in scp commands + other minor fixes #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions lib/beta_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
require 'ostruct'
require 'fileutils'
require 'cfpropertylist'
require 'beta_builder/archived_build'
require 'beta_builder/deployment_strategies'
require 'beta_builder/build_output_parser'
require File.dirname(__FILE__) + '/beta_builder/archived_build'
require File.dirname(__FILE__) + '/beta_builder/deployment_strategies'
require File.dirname(__FILE__) + '/beta_builder/build_output_parser'

module BetaBuilder
class Tasks < ::Rake::TaskLib
Expand Down Expand Up @@ -58,7 +58,7 @@ def build_arguments
def archive_name
app_name || target
end

def app_file_name
raise ArgumentError, "app_name or target must be set in the BetaBuilder configuration block" if app_name.nil? && target.nil?
if app_name
Expand All @@ -67,40 +67,40 @@ def app_file_name
"#{target}.app"
end
end

def ipa_name
if app_name
"#{app_name}.ipa"
else
"#{target}.ipa"
end
end

def built_app_path
if build_dir == :derived
"#{derived_build_dir_from_build_output}/#{configuration}-iphoneos/#{app_file_name}"
else
"#{build_dir}/#{configuration}-iphoneos/#{app_file_name}"
end
end

def derived_build_dir_from_build_output
output = BuildOutputParser.new(File.read("build.output"))
output.build_output_dir
output.build_output_dir
end

def built_app_dsym_path
"#{built_app_path}.dSYM"
end

def dist_path
File.join("pkg/dist")
end

def ipa_path
File.join(dist_path, ipa_name)
end

def deploy_using(strategy_name, &block)
if DeploymentStrategies.valid_strategy?(strategy_name.to_sym)
self.deployment_strategy = DeploymentStrategies.build(strategy_name, self)
Expand All @@ -110,28 +110,28 @@ def deploy_using(strategy_name, &block)
end
end
end

private

def define
namespace(@namespace) do
desc "Build the beta release of the app"
task :build => :clean do
xcodebuild @configuration.build_arguments, "build"
end

task :clean do
unless @configuration.skip_clean
xcodebuild @configuration.build_arguments, "clean"
end
end

desc "Package the beta release as an IPA file"
task :package => :build do
if @configuration.auto_archive
Rake::Task["#{@namespace}:archive"].invoke
end

FileUtils.rm_rf('pkg') && FileUtils.mkdir_p('pkg')
FileUtils.mkdir_p("pkg/Payload")
FileUtils.mv(@configuration.built_app_path, "pkg/Payload/#{@configuration.app_file_name}")
Expand All @@ -141,25 +141,25 @@ def define
FileUtils.mkdir('pkg/dist')
FileUtils.mv("pkg/#{@configuration.ipa_name}", "pkg/dist")
end

if @configuration.deployment_strategy
desc "Prepare your app for deployment"
task :prepare => :package do
@configuration.deployment_strategy.prepare
end

desc "Deploy the beta using your chosen deployment strategy"
task :deploy => :prepare do
@configuration.deployment_strategy.deploy
end

desc "Deploy the last build"
task :redeploy do
@configuration.deployment_strategy.prepare
@configuration.deployment_strategy.deploy
end
end

desc "Build and archive the app"
task :archive => :build do
puts "Archiving build..."
Expand Down
4 changes: 2 additions & 2 deletions lib/beta_builder/deployment_strategies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ def self.strategies
end
end

require 'beta_builder/deployment_strategies/web'
require 'beta_builder/deployment_strategies/testflight'
require File.dirname(__FILE__) + '/deployment_strategies/web'
require File.dirname(__FILE__) + '/deployment_strategies/testflight'

22 changes: 18 additions & 4 deletions lib/beta_builder/deployment_strategies/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def remote_installation_path
end
end
end

def prepare
plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}/Info.plist")
plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_file_name}/Info.plist")
plist_data = CFPropertyList.native_types(plist.value)
File.open("pkg/dist/manifest.plist", "w") do |io|
io << %{
Expand Down Expand Up @@ -82,9 +82,23 @@ def prepare
}
end
end

def deploy
system("scp pkg/dist/* #{@configuration.remote_host}:#{@configuration.remote_installation_path}")
cmd = []

cmd.push "scp"

if @configuration.remote_port
cmd.push "-P #{@configuration.remote_port}"
end

cmd.push "pkg/dist/*"
cmd.push "#{@configuration.remote_host}:#{@configuration.remote_installation_path}"

cmd = cmd.join(" ")

puts "* Running `#{cmd}`"
system(cmd)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/betabuilder.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require 'beta_builder'
require File.dirname(__FILE__) + '/beta_builder'