Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[supply][action] add download_apk_from_google_play action (and corresponding supply methods) #21315

Merged

Conversation

AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Jun 2, 2023

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary. N/A; actions documentation are auto-generated anyway

Motivation and Context

This adds a new download_apk_from_google_play action to download the Universal Code-Signed APK generated by Google after you uploaded the AAB.

This is especially useful when you use Play App Signing to sign your app, because in those cases you'll typically use the upload_to_google_play action to upload a .aab to Google Play Console (GPC), and let Google generate and code-sign the .apk files for that .aab (including split APKs for various architectures, but more importantly the Universal one compatible with all devices)

In those situations of using "Play App Signing", you can't use bundletool to generate the signed .apk from the .aab yourself because you don't have the code signing key (only Google has it), so the only option is to download the .apk from GPC.
And it's useful to get the universal, codesigned APK back because we can use it for running UI tests on it, making sure we run those on the exact APK that will be ultimately shipped to end users (including testing things that rely on code-signing signature checks for security and integrity validation).

Description

  • Supply::Client
    • Added the list_generated_universal_apks(package_name:, version_code:) method on Supply::Client to be able to call the generatedapks.list API endpoint
    • Added the download_generated_universal_apk(generated_universal_apk:, destination:) method on Supply::Client to be able to call the generatedapks.download API endpoint
    • Added those entry points to the spec/client_spec.rb tests
    • Added a GeneratedUniversalApk model to allow manipulating the result of those methods more easily
  • New Action
    • Added the download_universal_apk_from_google_play action as well as its unit tests (spec)

Testing Steps

Run the new Unit Tests:

bundle exec rspec fastlane/spec/actions_specs/download_universal_apk_from_google_play_spec.rb supply/spec/client_spec.rb

Add methods on the Supply client to list and download Universal Generated APKs from the Google Play Console — typically generated and code-signed by Google from the AAB you uploaded e.g. via the `upload_to_play_store`/`supply` action
Very useful when you use [Play App Signing](https://support.google.com/googleplay/android-developer/answer/9842756) and thus don't necessary have the signing key to produce the APK yourself.
In those cases, you typically only upload an AAB to GPC, then let Google code-sign and generate signed APKs from that AAB.
…` exceptions

Because most of the options that are detected as not being used directly by the action are in fact just passed along to Supply::Client.make_from_config
@AliSoftware AliSoftware force-pushed the supply/download-apk-from-google-play branch from 01d9661 to 546df7e Compare June 2, 2023 19:08
@rogerluan rogerluan added tool: supply upload_to_playstore tool: action labels Jun 4, 2023
@rogerluan rogerluan changed the title [Supply][Action] Add download_apk_from_google_play action (and corresponding Supply methods) [supply][action] add download_apk_from_google_play action (and corresponding supply methods) Jun 4, 2023
@AliSoftware
Copy link
Contributor Author

@joshdholtz Now that you're back from your vacation 😃 May I kindly ask a review of this one? I'd love to be able to finally use it in our automation soon 🙂

Comment on lines +43 to +44
expect(subject.class.method_defined?(:list_generatedapks)).to eq(true)
expect(subject.class.method_defined?(:download_generatedapk)).to eq(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That spec tests methods we expect to be defined on the AndroidPublisher::AndroidPublisherService internal client (not to be confused with the Supply::Client).

Those two particular ones that I added there are documented here in the AndroidPublisherService ruby doc:

And those are the ones that I call in the Supply::Client corresponding wrapper methods here and here, respectively.

So all that is correct, and consistent with how the rest of the spec and that file is written 🙂
(Plus, that spec/test passes on CI, while it would be red if those were not correct)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see. Thanks! I'm much less familiar with the Android code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! Took me some time to familiarize myself with the AndroidPublisher API and Supply code and specs as well when I wrote that PR 😅 🙂

@getaaron getaaron merged commit 5030f31 into fastlane:master Jul 6, 2023
8 checks passed
@AliSoftware AliSoftware deleted the supply/download-apk-from-google-play branch July 6, 2023 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool: action tool: supply upload_to_playstore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants