-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
Previous bug, we were not able to figure out the correct APIs to call. I have built sample code (see below) to do this. #12655 for reference.
Feature Request
Add create private app option to the supply action to facilitate creating Play Store listings for Managed Play.
I work with large enterprises that have to migrate apps to Managed Google Play. Some of these enterprises have 100+ internal applications and this process is quite painful to do this manually. I would love to steer them towards fastlane.
Motivation Behind Feature
Adding "create private play store listings" would be extremely helpful for developers with large amounts of applications for Managed Google Play (formally Play for Work).
It also helps automate cross platform. This feature exists for iOS and it's holding back enterprises I work with on adopting the other great features of fastlane/supply. This would be a significant enhancement so fastlane can be used for the whole automation flow.
Feature Description
Add feature similar to create from the produce (https://docs.fastlane.tools/actions/produce/) action.
There is a one time call that needs top made to Managed Play to enable private apps which returns a developer account identifier. It's OK if that needs to be done outside of fastlane, although would be cool if it could help. :)
fastlane supply enable_private_apps
Guide here: https://developers.google.com/android/work/play/custom-app-api/get-started
I have an account you can use for testing if that helps and can explain this part if needed.
Implementation:
Make sure to create an IAM role in the Google Cloud console for your enterprise and insert that into the service_account query param below.
Example OAuth call:
https://play.google.com/apps/publish/delegatePrivateApp?service_account=ACCOUNT@PROJECT-ID.iam.gserviceaccount.com&continueUrl=https://foo.bar/oauthredirectfastlane
The returning call will contain a developerAccount string that is a number to denote your account. You will need this to create private apps in the API.
fastlane supply create_private
Options for create: (Some ideas but not limited to)
-l, --language_code STRING Title (e.g. for example, "en_us for English", "de-AT" for Austrian German) (SUPPLY_LANGUAGE_CODE)
-t, --title STRING Title (SUPPLY_TITLE)
-d, --developerAccount STRING Title (SUPPLY_DEVELOPER_ACCOUNT) The developer account identifier returned from enabling private apps.
-v, --apk STRING APK Path (SUPPLY_APK) This should be a release build with V1 and V2 signatures for release.
Found a listing of supported keys under class Listing here.
This will not break any functionality. There are also no drawbacks.
Alternatives or Workarounds
The workaround is to use the Play REST API directly which is pretty rough for one missing feature.
Example code in Ruby to do this:
require "google/apis/playcustomapp_v1"
# Auth Info
KEYFILE = 'KEYFILE_FROM_SERVICEACCOUNT.json' # PATH TO JSON KEYFILE
DEVELOPER_ACCOUNT = "DEV ACCOUNT ID FROM ONE TIME OAUTH" # DEVELOPER ACCOUNT ID
# App Info
APK_PATH = "app-release.apk" # PATH TO SIGNED APK WITH V1+V2 SIGNATURES
APP_TITLE = "APP TITLE FOR"
LANGUAGE_CODE = "EN_US"
scope='https://www.googleapis.com/auth/androidpublisher'
credentials = JSON.parse(File.open(KEYFILE, 'rb').read)
authorization = Signet::OAuth2::Client.new(
:token_credential_uri => 'https://oauth2.googleapis.com/token',
:audience => 'https://oauth2.googleapis.com/token',
:scope => scope,
:issuer => credentials['client_id'],
:signing_key => OpenSSL::PKey::RSA.new(credentials['private_key'], nil),
)
authorization.fetch_access_token!
custom_app = Google::Apis::PlaycustomappV1::CustomApp.new title: APP_TITLE, language_code: LANGUAGE_CODE
play_custom_apps = Google::Apis::PlaycustomappV1::PlaycustomappService.new
play_custom_apps.authorization = authorization
returned = play_custom_apps.create_account_custom_app(
DEVELOPER_ACCOUNT,
custom_app,
upload_source: APK_PATH,
) do |created_app, error|
unless error.nil?
puts "Error: #{error}"
else
puts "Success: #{created_app}."
end
end