diff --git a/README.md b/README.md index fc9e267..e6f224a 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,21 @@ steps: ``` ## Additional packages -By default, sdkmanager installs "tools" and "platform-tools" packages. To install additional packages, call sdkmanager manually: +Input parameter `packages` controls which packages this action will install from Android SDK. + +Default value is `tools platform-tools`, supply an empty string to skip installing additional packages. + +Additional packages can be installed at a later time by calling sdkmanager manually. + ```yaml - name: Setup Android SDK uses: android-actions/setup-android@v3 + with: + packages: '' -- run: sdkmanager "ndk;26.1.10909125" "cmake;3.22.1" +# ... + +- run: sdkmanager tools platform-tools ``` ## SDK Version selection diff --git a/action.yml b/action.yml index d982c13..2b925c9 100644 --- a/action.yml +++ b/action.yml @@ -18,6 +18,11 @@ inputs: required: false default: 'true' + packages: + description: 'Additional packages to install' + required: false + default: 'tools platform-tools' + runs: using: node20 main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index b98dbf5..75324e5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -28269,8 +28269,19 @@ function run() { core.info('Accepting Android SDK licenses'); yield callSdkManager(sdkManagerExe, '--licenses', core.getBooleanInput('log-accepted-android-sdk-licenses')); } - yield callSdkManager(sdkManagerExe, 'tools'); - yield callSdkManager(sdkManagerExe, 'platform-tools'); + const packages = core + .getInput('packages', { required: false }) + .split(' ') + .map(function (str) { + return str.trim(); + }) + /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ + .filter(function (element, index, array) { + return element; + }); + for (const pkg of packages) { + yield callSdkManager(sdkManagerExe, pkg); + } core.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG); core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT); core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT); diff --git a/src/main.ts b/src/main.ts index b31dc92..f5ca205 100644 --- a/src/main.ts +++ b/src/main.ts @@ -156,8 +156,20 @@ async function run(): Promise { core.getBooleanInput('log-accepted-android-sdk-licenses') ) } - await callSdkManager(sdkManagerExe, 'tools') - await callSdkManager(sdkManagerExe, 'platform-tools') + + const packages = core + .getInput('packages', {required: false}) + .split(' ') + .map(function (str) { + return str.trim() + }) + /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ + .filter(function (element, index, array) { + return element + }) + for (const pkg of packages) { + await callSdkManager(sdkManagerExe, pkg) + } core.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG) core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT)