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

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

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

03c0e11ea6f2a3e08b3c46db5877c8e1?s=128

Jiro Nagashima

May 13, 2015
Tweet

Transcript

  1. fastlaneͱCircleCIͰ͸͡ΊΔ ΞϓϦ഑෍ͷఆظ࣮ߦ JIRO NAGASHIMAʗ@hedjirog

  2. γΰτͰίίϩΦυϧ WantedlyͷiOSΞϓϦ

  3. None
  4. γΰτͰίίϩΦυϧ • 7+ • গ਺ͷΤϯδχΞͰ։ൃ • CI؀ڥͷߏங ͸අ༻ରޮՌ͕େ͖͍ WantedlyͷiOSΞϓϦ

  5. γΰτͰίίϩΦυϧ ΞϓϦ഑෍ͷఆظ࣮ߦ

  6. Build Distribution Download Import

  7. Build Distribution Download Import

  8. Workflow

  9. Workflow Push

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

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

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

    1.0 ͕ϦϦʔε • Ϗϧυʙ഑෍ͷ࡞ۀΛworkflowԽ • CircleCI → Xcode 6.3 ʹରԠ • workflowͷఆظ࣮ߦ ΞϓϦ഑෍ͷఆظ࣮ߦ 2014.05
  14. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍

  15. γΰτͰίίϩΦυϧ 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
  16. γΰτͰίίϩΦυϧ 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
  17. γΰτͰίίϩΦυϧ 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
  18. γΰτͰίίϩΦυϧ 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
  19. γΰτͰίίϩΦυϧ 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
  20. γΰτͰίίϩΦυϧ fastlaneΛར༻ͨ͠ΞϓϦ഑෍ Action • ૢ࡞ຖʹ Action Λར༻͢Δ • ط੒ͷ Action

    ͕๛෋ʹ͋Δ • ֎෦πʔϧར༻ࢧԉ: • cocoapods, crashlytics, slack, etc. • fastlaneಠ֦ࣗு: • deliver, snapshot, sigh, cert, etc.
  21. γΰτͰίίϩΦυϧ 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 …
  22. γΰτͰίίϩΦυϧ CircleCIΛར༻ͨ͠ఆظ࣮ߦ

  23. γΰτͰίίϩΦυϧ CircleCIΛར༻ͨ͠ఆظ࣮ߦ circle.yml • circle.yml ϑΝΠϧʹهड़ΛՃ͑Δ deployment: beta: branch: master

    commands: - bundle exec fastlane deploy
  24. γΰτͰίίϩΦυϧ • fastlane • Rubyෆ׳ΕͰ΋ͦΕͬΆ͘ॻ͚Δ • Action ͷ ࢓༷͕υΩϡϝϯτͱҟͳΔ ͜ͱ͕͋ͬͨ

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