32
@xebiconfr #xebiconfr fastlane Automatisez votre vie (de dév iOS) JC Pastant

XebiCon'16 : Fastlane : Automatisez votre vie (de développeur iOS) Par Jean-Christophe Pastant, Développeur mobile chez Xebia

Embed Size (px)

Citation preview

@xebiconfr #xebiconfr

fastlaneAutomatisez votre

vie (de dév iOS)

JCPastant

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

●●●●

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

desc "Runs all the tests and generate reports"lane :run_tests do |options|end

desc "Builds an ipa"lane :build do |options|end

desc "Delivers a new build to appstore"lane :deploy do |options|end

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

app_identifier "fr.xebia.xebicon" # Xebicon bundle identifier

apple_id "[email protected]" # Xebia email address on iOS Dev Center

team_id "X3B1AR0XORZ" # Xebia team id

@xebiconfr #xebiconfr1.fastlane 2.Tests 3.Build 4.Deploy

$ fastlane my_lane --env debug

$ fastlane my_lane --env preprod

$ fastlane my_lane --env appstore

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :run_tests do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizescan(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane run_tests --env debug...Executed 83 tests, with 0 failures (0 unexpected) in 0.444 (0.509) seconds

+--------------------+-------+| Test Results |+--------------------+-------+| Number of tests | 83 || Number of failures | 0 |+--------------------+-------+

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :run_tests do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizescan(scheme: “Xebicon-#{scheme_env}”, code_coverage: true)slather(scheme: “Xebicon-#{scheme_env}”, proj: “Xebicon.xcodeproj”, html: true)

end

$ fastlane run_tests --env debug…Slathering...Successfully generated report at ‘.../reports/bdd/coverage/index.html’

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizegym(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane build --env beta...Code Sign error: No provisioning profiles found: No non–expired provisioning profiles were found.

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizeincrement_build_number(build_number: number_of_commits)gym(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane build --env beta...Code Sign error: No provisioning profiles found: No non–expired provisioning profiles were found.

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizesigh(output_path: "build", provisioning_name: "Xebicon #{scheme_env}")gym(scheme: “Xebicon-#{scheme_env}”)

end

$ fastlane build --env beta...Fetching profiles...Found 1 matching profile(s)Successfully downloaded provisioning profile...Installing provisioning profile…

Signing Xebicon.ipaSuccessfully exported and signed the ipa file: Xebicon.ipa

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :deploy do |options|build(options)deliver(skip_metadata: true, skip_screenshots: true)

end

$ fastlane deploy --env prod...Successfully uploaded package to iTunes Connect. It might take a few minutes until it’s visible online.

Finished the upload to iTunes Connect.

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :deploy do |options|build(options)crashlytics(groups: options[:to])

end

$ fastlane deploy --env preprod...Uploading the build to Crashlytics Beta. Time for some ☕�Build successfully uploaded to Crashlytics Beta

fastlane.tools just saved you 17 minutes!

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :deploy do |options|is_prod = [:prod, :appstore].include? lane_context[SharedValues::ENVIRONMENT]

build(options)crashlytics(groups: options[:to]) if !is_proddeliver(skip_metadata: true, skip_screenshots: true) if is_prod

end

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr

// Fastfileerror do |lane, exception|

slack(message: exception.message, success: false)end

lane :run_tests do |options|...slack(message: “Runned tests”, success: true)

end

lane :deploy do |options|env = lane_context[SharedValues::ENVIRONMENT]...slack(message: “Deployed on #{env}”, success: true)

end

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

def convention_env_valuesapp_name = ENV['APP_NAME']env = lane_context[SharedValues::ENVIRONMENT]scheme_env = env.capitalize

ENV['SCHEME'] ||= "#{app_name}-#{scheme_env}"ENV['XC_PROJECT'] ||= "#{app_name}.xcodeproj"ENV['DEPLOY_SERVICE'] ||= [:prod, :appstore].include? env ? "appstore" : "crashlytics"

ENV['SIGH_PROVISIONING_PROFILE_NAME'] ||= "#{app_name} #{scheme_env}"end

before_all doconvention_env_values()

end

@xebiconfr #xebiconfr

:test > :build > :deploy

Fastfile

1.fastlane 2.Tests 3.Build 4.Deploy

lane :run_tests do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizescan(scheme: “Xebicon-#{scheme_env}” ENV['SCHEME'], code_coverage: true)slather(proj: “Xebicon-#{scheme_env}” ENV["SCHEME"], scheme: “Xebicon.xcodeproj”

ENV["XC_PROJECT"], html: true)end

lane :build do |options|scheme_env = lane_context[SharedValues::ENVIRONMENT].capitalizesigh(output_path: "build", provisioning_name: "Xebicon #{scheme_env}")gym(scheme: “Xebicon-#{scheme_env}” ENV['SCHEME'])

end

lane :deploy do |options|is_prod = [:prod, :appstore].include? lane_context[SharedValues::ENVIRONMENT]

build(options)crashlytics(groups: options[:to]) if ENV['DEPLOY_SERVICE'] == 'crashlytics'deliver(skip_metadata: true, skip_screenshots: true) if ENV['DEPLOY_SERVICE'] == 'appstore'

end

@xebiconfr #xebiconfr

@xebiconfr #xebiconfr