LoginSignup
2

More than 3 years have passed since last update.

fastlaneを使って Internal App SharingにAABファイルをアップロードしてSlackにダウンロードリンクを飛ばす

Last updated at Posted at 2020-03-17

事前準備

  • fastlaneのバージョン2.139.0以上を使えるようにする
  • Internal App Sharingを使ってアプリの配布とダウンロードができるようにしておく
  • Google Play Developer APIのPublishing APIを使えるようにしておく
    • こちらの記事でやり方は紹介されているので参考にしてください https://qiita.com/itog/items/f382a7cc4a38bd079aab
      • 記事内ではKeyにP12を使用する方法になっていますがJSONにします。このJSONが後で必要になります。

実装

  desc 'Submit a new build to Google Play Store Internal App Sharing'
  lane :submit_play_store_internal_app_sharing do
    # cleanを先にすることでbuildフォルダを一度削除する
    # これによってbundle[Flavor][Variant]で生成されたaabファイルのみがoutput配下に存在するようになる
    # [Flavor]や[Variant]は適宜自分たちの環境に合わせて読み替えてください
    gradle(task: 'clean bundle[Flavor][Variant]') 

    download_url = upload_to_play_store_internal_app_sharing(
      package_name: '[your.app.package.name]',
      json_key: 'service-account.json', # 事前準備で用意したjsonを指定します
      # json_key_data   : json_keyでjsonファイルを指定するか生のjsonをこのkeyで指定する
      aab: lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH] # 最初のgradleアクションで生成されたaabのファイルパスが格納されている
      # aab_paths : '' aabを複数アップロードしたい場合はこちらのkeyを使って配列でpathを指定する
    )

    payload = { 'Download URL' => download_url }
    slack(
      message: ':android: :google-play: Submit PlayStore Internal App Sharing!',
      payload: payload,
      default_payloads: %i[git_branch last_git_commit_message]
    )
  end

上記が成功するとSlackにダウンロードURLが投稿されるので、このリンクを端末で開くことでアプリのインストールができます。
Screen_Shot_2020-03-17_at_12_27_09.png

アップロードするだけであればupload_to_play_store_internal_app_sharingだけ呼び出せば大丈夫です。

注意点

API経由でアップロードした場合一覧( https://play.google.com/apps/publish/internalappsharing/ )に表示されないので注意です。
(なにかやり方が行けないのかも?)

おわりに

完全に余談ですがInternal App SharingへのアップロードはGoogle Play Developer API v3が必要で、まずはそちらのバージョンアップが必要でした。
対応してくれた人には感謝しかないです。

このへんのはなし
https://github.com/fastlane/fastlane/issues/14573

参考URL

https://docs.fastlane.tools/actions/upload_to_play_store_internal_app_sharing/
https://docs.fastlane.tools/actions/gradle/
https://docs.fastlane.tools/actions/slack/
https://github.com/fastlane/fastlane/pull/15822/files

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
2