diff --git a/src/flows/android.js b/src/flows/android.js index 9e8e5bb..d927d40 100644 --- a/src/flows/android.js +++ b/src/flows/android.js @@ -62,13 +62,20 @@ const initAndroid = async ({ android, http, prompt, print, circle }, options) => } } -const initFastlane = async ({ system, android, template, filesystem, print }) => { +const initFastlane = async ({ system, android, template, filesystem, print, prompt }) => { const fastlanePath = system.which('fastlane') if (!fastlanePath) { print.info('No fastlane found, install...') await system.run('sudo gem install fastlane -NV') } + const { buildMode } = await prompt.ask({ + type: 'select', + name: 'buildMode', + message: 'Use Android App Bundle (.aab) or Android Package Kit (.apk) builds for Play Store?', + choices: ['.aab', '.apk'], + }) + const appId = android.getApplicationId() await template.generate({ @@ -80,7 +87,7 @@ const initFastlane = async ({ system, android, template, filesystem, print }) => await template.generate({ template: 'fastlane/android/Fastfile', target: 'android/fastlane/Fastfile', - props: { appId } + props: { appId, useAabBuilds: buildMode === '.aab' } }) await template.generate({ diff --git a/src/templates/fastlane/android/Fastfile b/src/templates/fastlane/android/Fastfile index ead05bf..43bc113 100644 --- a/src/templates/fastlane/android/Fastfile +++ b/src/templates/fastlane/android/Fastfile @@ -41,8 +41,9 @@ platform :android do build_number = number_of_commits() gradle( - task: 'assemble', - build_type: build_type, + <%if (props.useAabBuilds) { -%> task: 'bundle', + <% } else { -%> task: 'assemble', + <% } -%> build_type: build_type, properties: { "VERSION_CODE" => build_number } @@ -70,7 +71,6 @@ platform :android do if env != 'dev' and env != 'staging' and env != 'release' then raise 'env must be one of dev|staging|release' end - env_name = env.capitalize package_name_postfix = { 'release' => '', 'dev' => '.dev', @@ -79,7 +79,9 @@ platform :android do upload_to_play_store( package_name: "<%= props.appId %>#{package_name_postfix}", track: 'internal', - apk: "./app/build/outputs/apk/#{env}/release/app-#{env}-release.apk" + <% if (props.useAabBuilds) { -%> aab: "./app/build/outputs/bundle/#{env}/app.aab"-%> + <% } else { -%> apk: "./app/build/outputs/apk/#{env}/release/app-#{env}-release.apk"-%> + <% } %> ) end end