diff --git a/README.md b/README.md index 1f55b05..7b789a0 100644 --- a/README.md +++ b/README.md @@ -117,13 +117,14 @@ Finally, you can also specify an array of distribution lists that you want to al tf.distribution_lists = %w{Testers Internal} end -### Deploying to your own server +### Deploying to your own server (SSH) BetaBuilder also comes with a rather rudimentary web-based deployment task that uses SCP, so you will need SSH access to your server and appropriate permissions to use it. This works in the same way as the original iOS-BetaBuilder GUI app by generating a HTML template and manifest file that can be uploaded to a directly on your server. It includes links to install the app automatically on the device or download the IPA file. You will to configure betabuilder to use the `web` deployment strategy with some additional configuration: config.deploy_using(:web) do |web| + web.protocol = "ssh" web.deploy_to = "http://beta.myserver.co.uk/myapp" web.remote_host = "myserver.com" web.remote_directory = "/remote/path/to/deployment/directory" @@ -131,6 +132,21 @@ You will to configure betabuilder to use the `web` deployment strategy with some The `deploy_to` setting specifies the URL that your app will be published to. The `remote_host` setting is the SSH host that will be used to copy the files to your server using SCP. Finally, the `remote_directory` setting is the path to the location to your server that files will be uploaded to. You will need to configure any virtual hosts on your server to make this work. +### Deploying to your own server (FTP) + +Instead of SSH you can use FTP to deploy to a remote server. You still use the web deployment strategy but with a slightly different configuration than the SSH one: + + config.deploy_using(:web) do |web| + web.protocol = "ftp" + web.deploy_to = "http://beta.myserver.co.uk/myapp" + web.remote_host = "myserver.com" + web.username = "myftpusername" + web.password = "myftppassword" + web.remote_directory = "/remote/path/to/deployment/directory" + end + +The `deploy_to` setting specifies the URL that your app will be published to. The `remote_host` setting is the FTP host that will be used to copy the files to your server using FTP. Finally, the `remote_directory` setting is the path to the location to your server that files will be uploaded to. You will need to configure any virtual hosts on your server to make this work. The `username` setting is your FTP username and the `password` setting is your FTP password. + ## License This code is licensed under the MIT license. diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 878a6a7..7a8376b 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -2,6 +2,7 @@ require 'ostruct' require 'fileutils' require 'cfpropertylist' +require 'net/ftp' require 'beta_builder/archived_build' require 'beta_builder/deployment_strategies' require 'beta_builder/build_output_parser' diff --git a/lib/beta_builder/deployment_strategies/web.rb b/lib/beta_builder/deployment_strategies/web.rb index 7510d2b..329b7dc 100644 --- a/lib/beta_builder/deployment_strategies/web.rb +++ b/lib/beta_builder/deployment_strategies/web.rb @@ -18,7 +18,7 @@ def remote_installation_path end def prepare - plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}/Info.plist") + plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}.app/Info.plist") plist_data = CFPropertyList.native_types(plist.value) File.open("pkg/dist/manifest.plist", "w") do |io| io << %{ @@ -84,7 +84,29 @@ def prepare end def deploy - system("scp pkg/dist/* #{@configuration.remote_host}:#{@configuration.remote_installation_path}") + if @configuration.protocol == "ssh" then + system("scp pkg/dist/* #{@configuration.remote_host}:#{@configuration.remote_installation_path}") + elsif @configuration.protocol == "ftp" then + puts "Connecting to #{@configuration.remote_host} with username #{@configuration.username}" + Net::FTP.open(@configuration.remote_host, @configuration.username, @configuration.password) do |ftp| + begin + puts "Creating folder #{@configuration.remote_installation_path}" + ftp.mkdir(@configuration.remote_installation_path) + rescue Net::FTPError + puts "It looks like the folder is already there." + end + puts "Changing to remote folder #{@configuration.remote_installation_path}" + files = ftp.chdir(@configuration.remote_installation_path) + Dir['pkg/dist/*'].each do |f| + filename = File.basename(f) + puts "Uploading #{filename}" + ftp.putbinaryfile(f, filename, 1024) + end + end + + else + puts "No valid protocol definition found. Skipping deployment" + end end end end