iOS開発とGitLab CI

iOS開発とGitLab CI

2017/04/11 GitLab Meetup Tokyo #2 にてiOS開発におけるGitLab CIの活用方法について発表しました。

https://gitlab-jp.connpass.com/event/52276/

Ec3004a9ac8b0936b7eee6a9666a7857?s=128

Kenta Enomoto

April 11, 2017
Tweet

Transcript

  1. iOS։ൃͱGitLab CI 2017/04/11 GitLab Meetup Tokyo #2 #gitlabjp

  2. ࣗݾ঺հ • ӿຊ ݈ଠ • iOSΤϯδχΞ@iRidge, Inc. • Twitter: @enomotok_

    • GitHub: k-enomoto
  3. ࠓ೔࿩͢͜ͱ • iOS։ൃͷݱ৔ʹGitLab CIΛಋೖͨ͠࿩ • GitLab CIͰղܾͨ͠໰୊ • GitLab CIͷઃఆํ๏

    for iOS
  4. iOS։ൃݱ৔Ͱͷ໰୊ • Ϗϧυͷ௨Βͳ͍ϓϩδΣΫτ

  5. iOS։ൃݱ৔Ͱͷ໰୊ • Ϗϧυͷ௨Βͳ͍ϓϩδΣΫτ

  6. iOS։ൃݱ৔Ͱͷ໰୊ • ࠶ݱੑͷͳ͍खಈϏϧυ $ xcodebuild -scheme Foobar archive -archivePath Foobar

    -configuration "Debug" $ xcodebuild -exportArchive -exportOptionsPlist exportOptionsDev.plist - archivePath "Foobar.xcarchive" -exportPath "artifacts"
  7. iOS։ൃݱ৔Ͱͷ໰୊ • ʮ͜ͷipaͷ޲͖ઌͬͯ։ൃ؀ڥ͚ͩͬʁʯ

  8. iOS։ൃݱ৔Ͱͷ໰୊ • CIͷͳ͍؀ڥͰ։ൃ͢Δෆ҆
 - Ϗϧυ͸յΕ͍ͯͳ͍͔
 - Ϣχοτςετ͸յΕ͍ͯͳ͍͔ • ຖճipa࡞Δͷ໘౗


  9. GitLab CI

  10. GitLab CI • GitLabʹ෇ଐ͍ͯ͠ΔCIπʔϧ • CircleCI, Travis CIΈ͍ͨͳ΋ͷ • .gitlab-ci.yml

    • ؆୯ʹಋೖՄೳ
  11. • ߏ੒ GitLab CI ɾBSUJGBDUT QVTIΛݕ஌ HJUQVTI Developer Build Machine(Mac)

    ɾϏϧυ݁Ռ
  12. GitLab CI • Pipelines

  13. GitLab CI • Pipeline

  14. GitLab CI • Artifacts

  15. GitLab CIͷಋೖํ๏ • Setting up GitLab CI for iOS projects


    https://about.gitlab.com/2016/03/10/ setting-up-gitlab-ci-for-ios-projects/
  16. GitLab CIͷಋೖํ๏ • GitLab CIͰXcodeϓϩδΣΫτΛCI͢Δखॱ
 http://qiita.com/enomotok_/items/ 83935c1137203e1c2c0f • GitLab CIͰiOSΞϓϦΛϏϧυ͠ɺ


    ipaΛ഑෍͢Δ
 http://qiita.com/enomotok_/items/ 966144d6bc40ec093ac3
  17. GitLab CIͷಋೖํ๏ 1. ϏϧυϚγϯͷηοτΞοϓ 2. XcodeϓϩδΣΫτͷઃఆ 3. .gitlab-ci.yml 4. ϦϙδτϦͷઃఆ

  18. GitLab CIͷಋೖํ๏ 1. ϏϧυϚγϯͷηοτΞοϓ 2. XcodeϓϩδΣΫτͷઃఆ 3. .gitlab-ci.yml 4. ϦϙδτϦͷઃఆ

  19. ϏϧυϚγϯͷηοτΞοϓ • Mac
 - Xcode
 - iOS Certificates
 - Provisioning

    Profiles • GitLab Runner • ϏϧυϚγϯ͕ͳͯ͘΋OK
 -> ͻͱ·ͣ։ൃػΛϏϧυϚγϯͱ݉༻ʹ
  20. GitLab Runner • GitLabΛϙʔϦϯά • git pushΛݕ஌ͨ͠Β.gitlab-ci.ymlͷ
 εΫϦϓτΛ࣮ߦ͠ɺ݁ՌΛGitLabʹ௨஌ • GitLab

    CI Multi Runner͔Βվ໊
  21. GitLab CIͷಋೖํ๏ 1. ϏϧυϚγϯͷηοτΞοϓ 2. XcodeϓϩδΣΫτͷઃఆ 3. .gitlab-ci.yml 4. ϦϙδτϦͷઃఆ

  22. XcodeϓϩδΣΫτͷઃఆ • Shared
 Manage Schemes… -> SharedʹνΣοΫ
 {project_name}.xcodeproj/xcshareddata
 Λcommit


  23. GitLab CIͷಋೖํ๏ 1. ϏϧυϚγϯͷηοτΞοϓ 2. XcodeϓϩδΣΫτͷઃఆ 3. .gitlab-ci.yml 4. ϦϙδτϦͷઃఆ

  24. .gitlab-ci.yml GitLabCISandbox !"" .git !"" .gitignore !"" .gitlab-ci.yml !"" .swiftlint.yml

    !"" GitLabCISandbox !"" GitLabCISandbox.xcodeproj !"" GitLabCISandbox.xcworkspace !"" GitLabCISandboxTests !"" Podfile !"" Podfile.lock !"" Pods !"" README.md !"" exportOptionsAdHoc.plist !"" exportOptionsDev.plist #"" exportOptionsRelease.plist • ϓϩδΣΫτͷrootʹ.gitlab-ci.ymlΛ࡞੒

  25. .gitlab-ci.yml stages: - test - build .job_template: &job_definition before_script: -

    export LANG=en_US.UTF-8 - security unlock-keychain -p $PASS_PHRASE /Users/$USER_NAME/Library/Keychains/login.keychain - export DEVELOPER_DIR=/Applications/Xcode8.app/Contents/Developer <தུ> build_dev: <<: *job_definition stage: build script: - xcodebuild -scheme {scheme_name} archive -archivePath {your_path} -configuration "Debug" - xcodebuild -exportArchive -exportOptionsPlist exportOptionsDev.plist -archivePath “{yours}.xcarchive” -exportPath "artifacts/dev" artifacts: paths: - artifacts when: manual <ҎԼུ>
  26. .gitlab-ci.yml • stage
 ϏϧυͷεςʔδΛઃఆ • script
 ࣮ߦ͍ͨ͠εΫϦϓτΛهࡌ • artifacts
 GitLab͔ΒDL͍ͤͨ͞੒Ռ෺ͷύεΛࢦఆ

  27. .gitlab-ci.yml • only
 master, developͳͲಛఆͷϒϥϯνͷΈͰεΫϦϓτΛ࣮ߦ • when
 manualΛࢦఆ͢ΔͱɺGUIૢ࡞ΛܖػʹεΫϦϓτΛ࣮ߦ • cache


    ಛఆͷσΟϨΫτϦ഑ԼΛΩϟογϡ • tags
 ϏϧυϚγϯͷࢦఆʹ࢖༻
 https://docs.gitlab.com/ce/ci/yaml/
  28. GitLab CIͷಋೖํ๏ 1. ϏϧυϚγϯͷηοτΞοϓ 2. XcodeϓϩδΣΫτͷઃఆ 3. .gitlab-ci.yml 4. ϦϙδτϦͷઃఆ

  29. ϦϙδτϦͷઃఆ • Specific Runners

  30. ϦϙδτϦͷઃఆ • Secret Variables

  31. GitLab CIͷಋೖํ๏ • GitLab RunnerͷηοτΞοϓ • XcodeϓϩδΣΫτͷઃఆ • .gitlab-ci.yml •

    ϦϙδτϦͷઃఆ ✅ ✅ ✅ ✅
  32. GitLab CIͷಋೖํ๏ ઃఆͰ͖ͨ

  33. ໰୊ͩͬͨ͜ͱ • Ϗϧυͷ௨Βͳ͍ϓϩδΣΫτ • ࠶ݱੑͷͳ͍Ϗϧυ

  34. ໰୊Λղܾ • git pushͷ౓ʹϏϧυ, lint, Ϣχοτςετ • git pushͷ౓ʹipaΛੜ੒ •

    masterϒϥϯν΁ͷϚʔδͷ౓ʹ
 ϦϦʔεϏϧυ • artifactsʹ͸URL͕෇༩͞ΕΔͨΊڞ༗ָ͕
  35. ՝୊ • ͱ͸͍͑՝୊΋… • ϏϧυϚγϯͷXcodeͷόʔδϣϯ؅ཧ • Ϣχοτςετ͕ͨ·ʹࣦഊ • ূ໌ॻɺProvisioning Profilesͷ؅ཧ

    • ipaͷ഑෍
  36. ·ͱΊ • GitLab CIͰiOSϓϩδΣΫτΛखܰʹCI / CD • ܁Γฦ͠ͷ࡞ۀΛGitLab CIͰࣗಈԽ

  37. We are hiring.