Upgrade to Pro — share decks privately, control downloads, hide ads and more …

fastlaneとCircleCIではじめるアプリ配布の定期実行 / Continuous D...

fastlaneとCircleCIではじめるアプリ配布の定期実行 / Continuous Deployment with fastlane and CircleCI

Jiro Nagashima

May 13, 2015
Tweet

More Decks by Jiro Nagashima

Other Decks in Technology

Transcript

  1. γΰτͰίίϩΦυϧ • ഑෍πʔϧ • Fabric (Crashlytics Beta) • fastlane •

    Ϗϧυʙ഑෍ͷ࡞ۀΛworkflowԽ • CircleCI • workflowͷఆظ࣮ߦ ΞϓϦ഑෍ͷఆظ࣮ߦ
  2. γΰτͰίίϩΦυϧ • ഑෍πʔϧ • Fabric (Crashlytics Beta) • fastlane •

    Ϗϧυʙ഑෍ͷ࡞ۀΛworkflowԽ • CircleCI • workflowͷఆظ࣮ߦ ΞϓϦ഑෍ͷఆظ࣮ߦ
  3. γΰτͰίίϩΦυϧ • ഑෍πʔϧ • Fabric (Crashlytics Beta) • fastlane →

    1.0 ͕ϦϦʔε • Ϗϧυʙ഑෍ͷ࡞ۀΛworkflowԽ • CircleCI → Xcode 6.3 ʹରԠ • workflowͷఆظ࣮ߦ ΞϓϦ഑෍ͷఆظ࣮ߦ 2014.05
  4. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ શମ૾ lane :beta do # Import certificates cert_dir

    = "./fastlane/certificates" import_certificates( cert_paths: [ File.join(cert_dir, "apple.cer") ], key_paths: [ File.join(cert_dir, "development.p12"), File.join(cert_dir, "distribution.p12") ] ) # Download provisioning profiles sigh( app_identifier: "com.wantedly.app-qa", adhoc: true ) # Build ipa( scheme: "app", configuration: "QA" ) # Push to Crashlytics crashlytics( crashlytics_path: "./Pods/CrashlyticsFramework/Crashlytics.framework", groups: "Developers" ) end Build Distribution Download Import
  5. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ ূ໌ॻͷऔΓࠐΈ lane :beta do # Import certificates cert_dir

    = "./fastlane/certificates" import_certificates( cert_paths: [ File.join(cert_dir, "apple.cer") ], key_paths: [ File.join(cert_dir, "development.p12"), File.join(cert_dir, "distribution.p12") ] ) # Download provisioning profiles sigh( app_identifier: "com.wantedly.app-qa", adhoc: true ) # Build ipa( scheme: "app", configuration: "QA" ) # Push to Crashlytics crashlytics( crashlytics_path: "./Pods/CrashlyticsFramework/Crashlytics.framework", groups: "Developers" ) end Build Distribution Download Import
  6. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ Provisioning Profileͷμ΢ϯϩʔυ lane :beta do # Import certificates

    cert_dir = "./fastlane/certificates" import_certificates( cert_paths: [ File.join(cert_dir, "apple.cer") ], key_paths: [ File.join(cert_dir, "development.p12"), File.join(cert_dir, "distribution.p12") ] ) # Download provisioning profiles sigh( app_identifier: "com.wantedly.app-qa", adhoc: true ) # Build ipa( scheme: "app", configuration: "QA" ) # Push to Crashlytics crashlytics( crashlytics_path: "./Pods/CrashlyticsFramework/Crashlytics.framework", groups: "Developers" ) end Build Distribution Download Import
  7. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ ipaϑΝΠϧͷੜ੒ lane :beta do # Import certificates cert_dir

    = "./fastlane/certificates" import_certificates( cert_paths: [ File.join(cert_dir, "apple.cer") ], key_paths: [ File.join(cert_dir, "development.p12"), File.join(cert_dir, "distribution.p12") ] ) # Download provisioning profiles sigh( app_identifier: "com.wantedly.app-qa", adhoc: true ) # Build ipa( scheme: "app", configuration: "QA" ) # Push to Crashlytics crashlytics( crashlytics_path: "./Pods/CrashlyticsFramework/Crashlytics.framework", groups: "Developers" ) end Build Distribution Download Import
  8. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ ΞϓϦ഑෍ lane :beta do # Import certificates cert_dir

    = "./fastlane/certificates" import_certificates( cert_paths: [ File.join(cert_dir, "apple.cer") ], key_paths: [ File.join(cert_dir, "development.p12"), File.join(cert_dir, "distribution.p12") ] ) # Download provisioning profiles sigh( app_identifier: "com.wantedly.app-qa", adhoc: true ) # Build ipa( scheme: "app", configuration: "QA" ) # Push to Crashlytics crashlytics( crashlytics_path: "./Pods/CrashlyticsFramework/Crashlytics.framework", groups: "Developers" ) end Build Distribution Download Import
  9. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ Action • ૢ࡞ຖʹ Action Λར༻͢Δ • ط੒ͷ Action

    ͕๛෋ʹ͋Δ • ֎෦πʔϧར༻ࢧԉ: • cocoapods, crashlytics, slack, etc. • fastlaneಠ֦ࣗு: • deliver, snapshot, sigh, cert, etc.
  10. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ Action • ಠࣗʹ Action Λఆٛ͢Δ͜ͱ΋Մೳ class ImportCertificatesAction <

    Action def self.run(params) cert_paths = params[:cert_paths] key_paths = params[:key_paths] keychain = "ios-build.keychain" password = "ios-build" timeout_seconds = 3600 begin sh "security create-keychain -p #{password} #{keychain}" sh "security default-keychain -s #{keychain}" sh "security list-keychains -s #{keychain}" sh "security unlock-keychain -p #{password} #{keychain}" sh "security set-keychain-settings -t #{timeout_seconds} -l #{keychain}" cert_paths.each do |cert_path| sh "security import #{cert_path} -k #{keychain} -T /usr/bin/codesign" end key_paths.each do |key_path| # Don't use `sh` so as not to output a password. `security import #{key_path} -k #{keychain} -P #{ENV['P12_PASSWORD']} -T /usr/bin/codesign` raise "Password is not correct" unless $?.to_i == 0 end Helper.log.info 'Successfully import certificates .'.green rescue => ex Helper.log.error 'Failed to import certificates'.red raise ex end end …
  11. γΰτͰίίϩΦυϧ • fastlane • Rubyෆ׳ΕͰ΋ͦΕͬΆ͘ॻ͚Δ • Action ͷ ࢓༷͕υΩϡϝϯτͱҟͳΔ ͜ͱ͕͋ͬͨ

    (v1.0.2) • ಛఆͷύϥϝʔλ͕ར༻Ͱ͖ͳ͍ͳͲ • υΩϡϝϯτΑΓ΋࣮૷Λݟͨํ͕ૣ͍͜ͱ͕ଟ͍ • CircleCI • Xcodeͷ ࠷৽൛ରԠ͕ૣ͔ͬͨ ͷͰࠓޙʹظ଴Ͱ͖Δ • CIͰͷ ίʔυॺ໊͸೉қ౓ߴΊ • ࢼߦࡨޡͷ܁Γฦ͠Λ֮ޛ͢Δඞཁ͋Γ ิ଍