Skip to content
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
6 changes: 3 additions & 3 deletions betabuilder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<CFPropertyList>, ["~> 2.0.0"])
s.add_runtime_dependency(%q<uuid>, ["~> 2.3.1"])
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.1"])
s.add_runtime_dependency(%q<json>, ["~> 1.4.6"])
s.add_runtime_dependency(%q<json>)
else
s.add_dependency(%q<CFPropertyList>, ["~> 2.0.0"])
s.add_dependency(%q<uuid>, ["~> 2.3.1"])
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
s.add_dependency(%q<json>, ["~> 1.4.6"])
s.add_dependency(%q<json>)
end
else
s.add_dependency(%q<CFPropertyList>, ["~> 2.0.0"])
s.add_dependency(%q<uuid>, ["~> 2.3.1"])
s.add_dependency(%q<rest-client>, ["~> 1.6.1"])
s.add_dependency(%q<json>, ["~> 1.4.6"])
s.add_dependency(%q<json>)
end
end
2 changes: 1 addition & 1 deletion lib/beta_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(namespace = :beta, &block)

def xcodebuild(*args)
# we're using tee as we still want to see our build output on screen
system("#{@configuration.xcodebuild_path} #{args.join(" ")} | tee build.output")
system("#{@configuration.xcodebuild_path} #{args.join(" ")} | tee build.output; [ $PIPESTATUS -eq 0 ] || exit $PIPESTATUS")
end

class Configuration < OpenStruct
Expand Down
33 changes: 22 additions & 11 deletions lib/beta_builder/deployment_strategies/testflight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@ module BetaBuilder
module DeploymentStrategies
class TestFlight < Strategy
ENDPOINT = "https://testflightapp.com/api/builds.json"

def extended_configuration_for_strategy
proc do
def generate_release_notes(&block)
self.release_notes = block if block
end
end
end


def compress_generate_dsym
puts `zip -r -9 #{dsym_zip_path} #{@configuration.built_app_dsym_path}`
end

def dsym_zip_path
puts "Compressing dsym file in #{@configuration.built_app_path}"
@configuration.built_app_dsym_path + ".zip"
end

def deploy
release_notes = get_notes
compress_generate_dsym
payload = {
:api_token => @configuration.api_token,
:team_token => @configuration.team_token,
:file => File.new(@configuration.ipa_path, 'rb'),
:dsym => File.new(dsym_zip_path, 'rb'),
:notes => release_notes,
:distribution_lists => (@configuration.distribution_lists || []).join(","),
:notify => @configuration.notify || false,
Expand All @@ -32,32 +43,32 @@ def deploy
puts "ipa path: #{@configuration.ipa_path}"
puts "release notes: #{release_notes}"
end
if @configuration.dry_run

if @configuration.dry_run
puts '** Dry Run - No action here! **'
return
end

begin
response = RestClient.post(ENDPOINT, payload, :accept => :json)
rescue => e
response = e.response
end

if (response.code == 201) || (response.code == 200)
puts "Upload complete."
else
puts "Upload failed. (#{response})"
end
end

private

def get_notes
notes = @configuration.release_notes_text
notes || get_notes_using_editor || get_notes_using_prompt
end

def get_notes_using_editor
return unless (editor = ENV["EDITOR"])

Expand All @@ -70,12 +81,12 @@ def get_notes_using_editor
rm_rf(dir)
end
end

def get_notes_using_prompt
puts "Enter the release notes for this build (hit enter twice when done):\n"
@configuration.release_notes = gets_until_match(/\n{2}$/).strip
end

def gets_until_match(pattern, string = "")
if (string += STDIN.gets) =~ pattern
string
Expand Down