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

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

Sato Takeshi
October 03, 2017
800

 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

Sato Takeshi

October 03, 2017
Tweet

Transcript

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

    (ΞϓϦ͸iBeaconͰλάΛݕ஌) CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 9
  2. FrameworkΛެ։༻ͷΫϩʔϯͨ͠σΟϨΫτ Ϧʹίϐʔ git commit -m "some comment" git push origin

    master CIαʔϏεBitriseͰެ։SDKͷϏϧυ&ϦϦʔεΛࣗಈԽͨ͠࿩ 2017/10/3 21
  3. Ϗϧυͷखॱ • ඇެ։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
  4. ϩʔΧϧͷσΟϨΫτϦ . ├── 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
  5. 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
  6. 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
  7. 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
  8. # ϦϦʔεόʔδϣϯ໊ CI_RELEASE_VERSION=`date +"v%Y%m%d%H%M%S"` # ϦϦʔεϒϥϯν໊ CI_RELEASE_BRANCH="release/${CI_RELEASE_VERSION}" # ϦϞʔτϦϙδτϦ CI_REMOTE_REPOSITORY="[email protected]: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
  9. # ϦϦʔεϒϥϯν࡞੒ 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