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

Fastlane, Continuous Deployment to iOS

Fastlane, Continuous Deployment to iOS

Continuous Deployment to iOS

yohei sugigami

February 28, 2015
Tweet

More Decks by yohei sugigami

Other Decks in Technology

Transcript

  1. Continuous Deployment to iOS
    yohei SUGIGAMI
    deliver • snapshot • frameit • PEM • sigh • produce

    View Slide

  2. View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. HOT!!
    Continuous Deployment to iOS

    View Slide

  7. IUUQLJTIJLBXBLBUTVNJIBUFOBCMPHDPNFOUSZ
    Travis CIͰiOSΞϓϦͷϦϦʔε࡞ۀΛࣗಈԽ͢Δ

    View Slide

  8. Mattt Thompson

    View Slide

  9. Ship.io

    View Slide

  10. View Slide

  11. Build a workflow by the lane

    View Slide

  12. ˔εΫϦʔϯγϣοτΛ࡞Δ
    ˔ϕʔλ൛ͷϏϧυͱ഑෍Λߦ͏
    ˔Ϗϧυͱ"QQ4UPSF΁ͷఏग़Λߦ͏

    ɹϓϩϏδϣχϯάϓϩϑΝΠϧͷߋ৽
    ɹ৽͍͠εΫϦʔϯγϣοτͷ࡞੒
    "QQ4UPSF΁ͷΞοϓϩʔυ

    ˔$*ͷதͰ࢖͏

    ɹ+FOLJOTɺ5SBWJT$*ɺ$JSDMF$*
    Use Case

    View Slide

  13. ˒̍,̑̌̌

    View Slide

  14. Meet the fastlane family

    View Slide

  15. View Slide

  16. View Slide

  17. Lets’s install

    View Slide

  18. Lets’s install
    Install Command Line Tools

    View Slide

  19. Install
    $ sudo gem install fastlane


    Successfully installed fastlane-0.1.9
    Successfully installed fastlane_core-0.1.1
    Successfully installed deliver-0.7.10
    Successfully installed snapshot-0.4.9
    Successfully installed frameit-0.2.2
    Successfully installed pem-0.3.4
    Successfully installed sigh-0.3.3
    Successfully installed produce-0.1.4
    $ brew install xctool (for test)

    $ brew install imagemagick (for frameit)

    Options


    View Slide

  20. $ cd [your_project_folder]
    $ fastlane init


    INFO This setup will help you get up and running in no time.
    INFO First, it will move the config files from `deliver` and `snapshot`
    INFO into the subfolder `fastlane`.
    INFO Fastlane will check what tools you're already using and set up
    INFO the tool automatically for you. Have fun!
    Do you want to get started? This will move your Deliverfile and Snapfile (if they exist) (y/n)
    y
    Do you have everything commited in version control? If not please do so! (y/n)
    y
    INFO Created new folder './fastlane'.
    INFO ------------------------------
    INFO To not re-enter your username and app identifier every time you run one of the fastlane tools
    or fastlane, these will be stored from now on.
    App Identifier (com.krausefx.app): com.hoge.fuga
    Your Apple ID: [email protected]
    INFO Created new file './fastlane/Appfile'. Edit it to manage your preferred app metadata
    information.
    Do you want to setup 'deliver', which is used to upload app screenshots, app metadata and app
    updates to the App Store or Apple TestFlight? (y/n)
    y
    INFO Loading up 'deliver', this might take a few seconds
    Phantomjs does not appear to be installed in /Users/hoge/.phantomjs/1.9.8/darwin/bin/phantomjs,
    installing!
    Init

    View Slide

  21. Successfully installed phantomjs. Yay!
    Removed temporarily downloaded files.
    Do you want Deliver to automatically create the Deliverfile for you based on your current app? The
    app has to be in the App Store to use this feature. (y/n)
    y
    First, you need to login with your iTunesConnect credentials.
    This is necessary to fetch the latest metadata from your app and use it to create a Deliverfile for
    you.
    If you have previously entered your credentials already, you will not be asked again.
    No username or password given. You can set environment variables:
    DELIVER_USER, DELIVER_PASSWORD
    -------------------------------------------------------------------------------------
    The login information you enter will be stored in your Mac OS Keychain
    More information about that on GitHub: https://github.com/KrauseFx/CredentialsManager
    -------------------------------------------------------------------------------------
    Password (for [email protected]): **********
    INFO Could not find Apple ID based on the app identifier in the US App Store. Maybe the app is not
    yet in the store?
    INFO You can provide the Apple ID of your app using `apple_id '974739333'` in your `Deliverfile`


    Apple ID of your app (e.g. 284882215): 284882215


    INFO Going to download app metadata from iTunesConnect
    DEBUG [Transporter Output]: INFO: Transporter is searching for updated software components.
    Init

    View Slide

  22. ERROR [Transporter Error Output]: Your Apple ID or password was entered incorrectly. (-20101)
    It seems like the username or password for the account '[email protected]' is wrong.
    Do you want to re-enter your username and password? (y/n)
    n
    DEBUG [Transporter Output]: DBG-X: The error code is: -20101
    FATAL Transporter transfer failed.
    WARN
    ERROR Your Apple ID or password was entered incorrectly. (-20101)
    FATAL Return status of iTunes Transporter was 1: Your Apple ID or password was entered incorrectly.
    (-20101)
    ERROR Your Apple ID or password was entered incorrectly. (-20101)
    Return status of iTunes Transporter was 1: Your Apple ID or password was entered incorrectly.
    (-20101)
    FATAL Could not download metadata from iTunes Connect. Do you have special characters in your
    password (Like ' or ")?
    FATAL Error occured with the setup program! Reverting changes now!
    INFO Deleting the 'fastlane' folder
    /Users/hoge/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/deliver-0.7.10/lib/deliver/
    app_metadata.rb:302:in `read': No such file or directory @ rb_sysopen - /tmp/968761649.itmsp//
    metadata.xml (Errno::ENOENT)
    (ɾ_ɾ;)
    Your Apple ID or password was entered incorrectly

    View Slide

  23. IPVSTBHP ˏ@ˏ

    Alpha-numeric password works fine

    View Slide

  24. INFO iTunes Transporter successfully finished its job
    DEBUG [Transporter Output]: DBG-X: Returning 0
    INFO Successfully downloaded the latest package from iTunesConnect.
    INFO Modifying version '1.0.0' of app com.hoge.fuga
    Successfully created new metadata JSON file at './fastlane//deliver/metadata.json'
    Successfully created new Deliverfile at './fastlane//Deliverfile'
    Do you want to setup 'snapshot', which will help you to automatically take screenshots of your iOS
    app in all languages/devices? (y/n)
    y
    INFO Loading up 'snapshot', this might take a few seconds
    DEBUG Found 10 simulators.
    Successfully created SnapshotHelper.js './fastlane//SnapshotHelper.js'
    Successfully created new UI Automation JS file at './fastlane//snapshot.js'
    Successfully created new UI Automation JS file for iPad at './fastlane//snapshot-iPad.js'
    Successfully created new Snapfile at './fastlane/Snapfile'
    Do you want to use 'sigh', which will maintain and download the provisioning profile for your app?
    (y/n)
    y
    INFO 'deliver' enabled.
    INFO 'snapshot' enabled.
    INFO 'xctool' not enabled.
    INFO 'cocoapods' enabled.
    INFO 'sigh' enabled.
    INFO Created new file './fastlane/Fastfile'. Edit it to manage your own deployment lanes.
    INFO Successfully finished setting up fastlane
    Install

    View Slide

  25. Fastfile

    View Slide

  26. before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    # sh "./customShellScript.sh"
    team_id "Q2CBPK58CA"

    cocoapods
    increment_build_number
    xctool :test
    ipa({
    workspace: "MyApp.xcworkspace",
    configuration: "Debug",
    scheme: "MyApp",
    })
    end
    before_all

    View Slide

  27. lane :beta do
    sigh
    increment_build_number
    ipa({
    workspace: "RSSReader.xcworkspace",
    configuration: "Release",
    scheme: "RSSReader",
    clean: ""
    })
    deliver :skip_deploy, :beta
    end
    lane

    View Slide

  28. after_all do |lane|
    slack({
    message: "Successfully deployed [App]",
    success: true,
    channel: 'development'
    })
    end
    error do |lane, exception|
    # Something bad happened
    end
    after_all

    View Slide

  29. lane :beta do
    snapshot
    sigh
    crashlytics({

    # path to your 'Crashlytics.framework'
    crashlytics_path: './Crashlytics.framework',
    api_token: '...',
    build_secret: '...',
    ipa_path: './app.ipa'
    })
    end
    Crashlytics Beta

    View Slide

  30. lane :beta do
    snapshot
    sigh

    deploygate({
    api_token: '...',
    user: 'target username or organization name',
    ipa: './ipa_file.ipa',
    message: "Build",
    })
    end
    DeployGate

    View Slide

  31. Snapshot

    View Slide

  32. Snapshot
    $ snapshot


    OR
    lane :snapshot do
    snapshot
    end


    ./fastlane/Fastfile
    $ fastlane snapshot


    View Slide

  33. Download zip to specify folder

    View Slide

  34. View Slide

  35. Config snapshot & frameit
    #import "SnapshotHelper.js"
    var target = UIATarget.localTarget();
    var app = target.frontMostApp();
    var window = app.mainWindow();
    target.delay(3)
    captureLocalizedScreenshot("0-LandingScreen")
    ./fastlane/snapshot.js
    ./fastlane/Snapfile
    devices([
    "iPhone 6",
    "iPhone 6 Plus",
    "iPhone 5",
    "iPhone 4s",
    "iPad Air"
    ])
    languages([
    "en-US",
    "de-DE",
    "es-ES"
    ])
    Device, Language, Timing

    View Slide

  36. AppleTestFlight

    View Slide

  37. Initial setting for versioning

    View Slide

  38. apple_id "9999999999"
    dir = File.expand_path(File.dirname(__FILE__)) + "/.."
    ipa do
    "#{dir}/RSSReader.ipa"
    end
    beta_ipa do
    "#{dir}/RSSReader.ipa"
    end
    ./fastlane/Deliverfile

    View Slide

  39. Versioning by agvtool

    View Slide

  40. INFO Driving the lane 'beta'
    INFO Step: team_id
    INFO Setting Team ID to 'xxxxxxxxxx' for all build steps
    INFO Step: sigh
    INFO Login into iOS Developer Center
    INFO Login successful
    INFO Fetching all available provisioning profiles...
    INFO Checking if profile is available. (72 profiles found)
    INFO Downloading profile...
    INFO Successfully downloaded provisioning profile
    INFO Exported provisioning profile to '/Users/susieyy/go/src/github.com/wantedly/swift-rss-
    sample/Distribution_com.susieyy.rss.mobileprovision'
    INFO open '/Users/susieyy/go/src/github.com/wantedly/swift-rss-sample/
    Distribution_com.susieyy.rss.mobileprovision'
    INFO Step: increment_build_number
    INFO agvtool next-version -all
    INFO Step: ipa
    INFO ipa build -w "RSSReader.xcworkspace" -c "Release" -s "RSSReader" --clean
    INFO Step: deliver
    INFO Got all information needed to deploy a new update ('1.0.0') for app 'com.susieyy.rss'
    INFO Uploading ipa file to iTunesConnect
    INFO Going to upload updated app to iTunesConnect
    INFO iTunes Transporter successfully finished its job
    INFO Successfully uploaded package to iTunesConnect. It might take a few minutes until it's
    visible online.
    INFO fastlane.tools finished successfully
    ./fastlane/Deliverfile
    $ fastlane beta


    View Slide

  41. iTunes Connect

    View Slide

  42. Conclusion
    ˔/PNBEPJP TIFO[FO
    ʴ3BLF .BLFͳײ͡
    ˔εΫϦʔϯγϣοτͷ࡞੒͸ศར
    ˔·ͩ·ͩൃల్্ͳͷͰࠓޙΛݟकΓ͍ͨ

    View Slide

  43. ΤϯδχΞืूͯ͠·͢ɿʣ
    ͓͠·͍

    View Slide