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

CIサービスBitriseで公開SDKのビルド&リリースを自動化した話

53e2d354b3299d64a54af680865516d5?s=47 Sato Takeshi
October 03, 2017
630

 CIサービスBitriseで公開SDKのビルド&リリースを自動化した話

俺コン Vol.1 / Day. 2にて発表した内容です。
https://orecon.connpass.com/event/64285/

プロポーザル
https://iosdc.jp/2017/node/1489

MamorioSDK 
https://github.com/otoshimono/mamorio-sdk-ios-bin

53e2d354b3299d64a54af680865516d5?s=128

Sato Takeshi

October 03, 2017
Tweet

Transcript

  1. CIαʔϏεBitriseͰެ։SDKͷϏϧυ &ϦϦʔεΛࣗಈԽͨ͠࿩ 2017೥10݄3೔ Զίϯ Vol.1 / Day. 2 ࠤ౻߶࢜ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩

    2017/10/3 1
  2. Who am I ࠤ౻߶࢜ (@hatakenokakashi) MAMORIOגࣜձࣾͰiOSΤϯδχΞΛ ͍ͯ͠·͢ɻ http://blog.personal-factory.com/ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3

    2
  3. ฆࣦ๷ࢭλάMAMORIO CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 3

  4. ฆࣦ௨஌ མͱͨ͠Β௨஌Λग़͢ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 4

  5. Ϋϥ΢υτϥοΩϯά ΈΜͳͰ୳͢ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 5

  6. SDKΛެ։ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 6

  7. ࠓ೔ͷ໨࣍ • MAMORIOͷ։ൃʹ͍ͭͯ • Biriseʹ͍ͭͯ • fastlaneʹ͍ͭͯ • SDKΛࣗಈϏϧυ&ϦϦʔε CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩

    2017/10/3 7
  8. MAMORIOͷ։ൃʹͭ ͍ͯ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 8

  9. SDKͷػೳ • Ϣʔβʔొ࿥ • ϢʔβʔϩάΠϯɺϩάΞ΢τ • MAMORIOλάͷొ࿥ • MAMORIOλάͷݕ஌ •

    (ΞϓϦ͸iBeaconͰλάΛݕ஌) CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 9
  10. SDKͱͯ͠ެ։ • ιʔε͸ެ։͠ͳ͍ • ϏϧυࡁΈͷFrameworkΛެ։͢Δ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 10

  11. ϦϙδτϦมભ ݄೔ มભ 2015೥5݄ MAMORIOΞϓϦϦϦʔε 2016೥7݄ʙ APPϦϙδτϦ͔ΒίΞػೳΛϓϥΠϕ ʔτSDKϦϙδτϦΛҠߦ 2017೥2݄ʙ ެ։ϦϙδτϦΛ࡞੒͠ɺϓϨϕʔτ

    SDKϦϙδτϦ͔ΒϏϧυࡁΈ FrameworkΛެ։ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 11
  12. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 12

  13. Bitriseʹ͍ͭͯ • ϞόΠϧΞϓϦઐ༻CIαʔϏε • iOSɺAndroidɺXamarinͰϏϧυՄೳ • ϏϧυઃఆΛGUIͰઃఆՄೳ(Workflows) • Ϗϧυ͕࣌ؒ10෼Ҏ಺ͳΒແྉͷϓϥϯ͋Γ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩

    2017/10/3 13
  14. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 14

  15. fastlane • iOS޲͚Ϗϧυπʔϧ • XcodeͷϏϧυɺΞʔΧΠϒɺূ໌ॻߋ৽ΛίϚϯυϥΠϯ Ͱ࣮ߦՄೳ • Android޲͚ͷίϚϯυϥΠϯπʔϧ΋ۙ೥௥Ճ͞Εͨ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3

    15
  16. SDKΛࣗಈϏϧυ&ϦϦ ʔε CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 16

  17. ࣗಈԽ͠ͳ͍ͱͲ͏ͳΔ͔ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 17

  18. XcodeʹͯMAMORIOSDKͷεΩʔϚʔͰ ⌘+B CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 18

  19. Productsάϧʔϓ͔ΒӈΫϦοΫͰFinderදࣔ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 19

  20. FrameworkΛ֬ೝ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 20

  21. FrameworkΛެ։༻ͷΫϩʔϯͨ͠σΟϨΫτ Ϧʹίϐʔ git commit -m "some comment" git push origin

    master CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 21
  22. ਏ͍ (´ɾТɾʆ) CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 22

  23. ࣗಈԽ͠·͢ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 23

  24. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 24

  25. Ϗϧυͷखॱ • ඇެ։SDKͷGitϦϙδτϦʔΛΫϩʔϯ • BuildϑΥϧμʹެ։༻SDKͷGitϦϙδτϦΛΫϩʔϯ • fastlaneͰSDKΛϏϧυɻFrameworkΛBuildϑΥϧμʹग़ྗ • SDKͷCHANGELOG.mdͱREADME.mdΛίϐʔ •

    GitͰCommitɺϒϥϯν੾ͬͯɺެ։༻SDKͷGitHub΁Push • ݁ՌΛSlackʹૹ৴ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 25
  26. BitriseͷWorkflowΛ ઃఆ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 26

  27. ϩʔΧϧͷσΟϨΫτϦ . ├── CHANGELOG.md ├── MamorioSDK │ ├── MamorioSDK #

    ιʔε │ ├── MamorioSDK.xcodeproj │ ├── MamorioSDKTests │ ├── build # ެ։༻ϦϙδτϦ࡞ۀσΟϨΫτϦ │ │ └── mamorio-sdk-ios-bin │ │ ├── CHANGELOG.md │ │ ├── MamorioSDK.framework │ │ └── README.md │ ├── fastlane └── README.md CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 27
  28. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 28

  29. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 29

  30. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 30

  31. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 31

  32. CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 32

  33. xcbuildͰϏϧυ desc "Build Framework" lane :build_framework do |values| xcbuild( project:

    "MamorioSDK.xcodeproj", scheme: 'MamorioSDK', configuration: 'Debug', build_settings: { CONFIGURATION_BUILD_DIR: './build/mamorio-sdk-ios-bin' #ग़ྗઌΛࢦఆ͢Δ }, force: true ) end CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 33
  34. ΞϓϦΛΞʔΧΠϒ͠ɺIPAϑΝΠϧΛੜ੒͢ΔΞΫγϣϯ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 34

  35. ࠓճ͸Ϗϧυͯ͠FrameworkΛग़ྗ͍ͨ͠ͷͰxcbuildΛ࢖͏ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 35

  36. gitͰίϛοτͱϓογϡ Λߦ͏ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 36

  37. before_all do ENV["TAG_VERSION"] = "v1.0.1" ENV["TAG_COMMENT"] = "ࣗಈϏϧυʹͯϦϦʔε" end desc

    "git pushΛshell scriptͰߦ͏" lane :git_push_via_shell do |values| tag_bersion = ENV["TAG_VERSION"] tag_comment = ENV["TAG_COMMENT"] sh("sh ./bin_push.sh #{tag_bersion} #{tag_comment}") end CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 37
  38. sh • fastlaneʹͯshellεΫϦϓτΛ࣮ߦ͢ΔΞΫγϣϯ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 38

  39. bin_push.sh #!/bin/bash #Ҿ਺͔Βม਺Λ࡞੒ TAG_VERSION=$1 TAG_COMMENT=$2 # gitϢʔβઃఆ git config user.email

    "<Commit User Email>" #ίϛοτϢʔβͷ༗ޮͳϝʔϧΞυϨε git config user.name "<User Name>" #ίϛοτϢʔβͷ໊લ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 39
  40. # ϦϦʔεόʔδϣϯ໊ CI_RELEASE_VERSION=`date +"v%Y%m%d%H%M%S"` # ϦϦʔεϒϥϯν໊ CI_RELEASE_BRANCH="release/${CI_RELEASE_VERSION}" # ϦϞʔτϦϙδτϦ CI_REMOTE_REPOSITORY="git@github.com:otoshimono/mamorio-sdk-ios-bin.git"

    # ΧϨϯτσΟϨΫτϦΛ֬ೝ echo $PWD #SDKͷREADMEΛbinʹίϐʔ cp ../../README.md ../build/mamorio-sdk-ios-bin #SDKͷCHANGELOGΛbinʹίϐʔ cp ../../CHANGELOG.md ../build/mamorio-sdk-ios-bin # ࡞ۀσΟϨΫτϦΛҠಈ cd ../build/mamorio-sdk-ios-bin CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 40
  41. # ϦϦʔεϒϥϯν࡞੒ git checkout -b ${CI_RELEASE_BRANCH} #มߋϑΝΠϧΛΛ͢΂ͯ௥Ճ git add --all

    :/ #ίϛοτ git commit -m "[auto] release branch (${CI_RELEASE_VERSION})" #λάΛ࡞੒ git tag -a "${TAG_VERSION}" -m "${TAG_COMMENT}" #ϦϞʔτʹϓογϡ git push ${CI_REMOTE_REPOSITORY} ${CI_RELEASE_BRANCH} ɹ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 41
  42. fastlanenʹ͸Gitૢ࡞ͷΞΫγϣϯ͕ͨ͘͞Μ ͋Δ͕... • ͲΕ΋ಉ͡ϦϙδτϦ্Ͱͷૢ࡞ • ඇެ։ϦϙδτϦͰϏϧυͯ͠ެ։ϦϙδτϦͰϓογϡ͢ Δํ๏͕Θ͔Βͳ͔ͬͨɻ • ۪௚ʹshellεΫϦϓτͰ࣮ߦͨ͠ɻ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩

    2017/10/3 42
  43. ݁ՌΛSlackʹૹ৴ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 43

  44. SlackͰWebhookURLΛऔಘ https://slack.com/services/new/incoming-webhook CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 44

  45. bitriseʹWebhookURLͱϝοηʔδొ࿥ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 45

  46. ࣮ߦ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 46

  47. ඇެ։SDKϦϙδτϦͰgit push CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 47

  48. bitriseͰϏϧυ͕࢝·Δ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 48

  49. ެ։༻GitHub΁ϓογϡ͞ΕΔ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 49

  50. SlackͰ݁Ռ௨஌ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 50

  51. ! CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 51

  52. ·ͱΊ • BitriseͱfastlaneͰSDKϏϧυͱϓογϡΛࣗಈԽͨ͠ • Bitriseͷworkflow͸ઃఆ؆୯ɻ • fastlaneɺࣗ෼ͷ͍ͨ͜͠ͱ͕ΞΫγϣϯʹͳ͍ͳΒ۪௚ʹ shellεΫϦϓτ࣮ߦ͢Δͷ΋͋Γ CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3

    52