wheatandcatの開発ブログ

React Nativeで開発しているペペロミア & memoirの技術系記事を投稿してます

react-nativeのfastlaneでfabric自動化(ios/android)

push通知実装はできたけど、デプロイできなかったので、今日はfabricの紹介 githubに動くsource上げてます

github.com

ios

取り敢えず、手元で動かす前提で実装 ciだと証明書関係があるので、matchを実装しる必要がある

match - fastlane docs

  • ios/fastlane/Fastfile
default_platform(:ios)

platform :ios do
  desc "create ipa"
  lane :create_ipa do

    sigh(
      force: false,
      app_identifier: "org.reactjs.native.example.FastlaneWithFabric",
      adhoc: true,
    )

    increment_version_number(
      version_number: "0.0.0",
      xcodeproj: "FastlaneWithFabric.xcodeproj"
    )

    increment_build_number(
      build_number: Time.now.strftime("%Y%m%d%H%M"),
      xcodeproj: "FastlaneWithFabric.xcodeproj"
    )

    build_app(
      scheme: "FastlaneWithFabric",
      output_name: "FastlaneWithFabric.ipa",
      export_method: "ad-hoc"
    )

  end

  desc "deploy fabric"
  lane :fabric do

    crashlytics(
      crashlytics_path: "./Crashlytics.framework",
      api_token: ENV["FABRIC_API_TOKEN"],
      build_secret: ENV["FABRIC_API_SECRET"],
      ipa_path: 'FastlaneWithFabric.ipa',
      notes: "by fastlane",
      notifications: true,
      groups: ENV["FABRIC_GROUP"],
    )

  end

end

android

androidの方は↓を導入したらいけました。(android studioプラグインの方はうまくいかなかったので。。。)

github.com

default_platform(:android)

platform :android do

  desc "Submit a new Beta Build to Crashlytics Beta"
  lane :create_apk do

    gradle(task: "clean")
    
    gradle(task: "assembleRelease")

    sh("jarsigner", "-storepass", ENV["KEY_STORE_PASSWORD"], "-verbose", "-keystore", "../app/android-release.keystore", "../app/build/outputs/apk/app-release-unsigned.apk", "android-release")

  end

  desc "deploy fabric"
  lane :fabric do

    crashlytics(
      api_token: ENV["FABRIC_API_TOKEN"],
      build_secret: ENV["FABRIC_API_SECRET"],
      apk_path: 'app/build/outputs/apk/app-release-unsigned.apk',
      notes: "by fastlane",
      notifications: true,
      groups: ENV["FABRIC_GROUP"],
    )

  end

end