Implement action input parameter 'packages'

This commit is contained in:
Vilius Sutkus '89 2023-11-25 17:41:26 +02:00
parent a86cdbf03d
commit eb7920b260
4 changed files with 43 additions and 6 deletions

View file

@ -39,12 +39,21 @@ steps:
``` ```
## Additional packages ## 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 ```yaml
- name: Setup Android SDK - name: Setup Android SDK
uses: android-actions/setup-android@v3 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 ## SDK Version selection

View file

@ -18,6 +18,11 @@ inputs:
required: false required: false
default: 'true' default: 'true'
packages:
description: 'Additional packages to install'
required: false
default: 'tools platform-tools'
runs: runs:
using: node20 using: node20
main: 'dist/index.js' main: 'dist/index.js'

15
dist/index.js vendored
View file

@ -28269,8 +28269,19 @@ function run() {
core.info('Accepting Android SDK licenses'); core.info('Accepting Android SDK licenses');
yield callSdkManager(sdkManagerExe, '--licenses', core.getBooleanInput('log-accepted-android-sdk-licenses')); yield callSdkManager(sdkManagerExe, '--licenses', core.getBooleanInput('log-accepted-android-sdk-licenses'));
} }
yield callSdkManager(sdkManagerExe, 'tools'); const packages = core
yield callSdkManager(sdkManagerExe, 'platform-tools'); .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.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG);
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT); core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT);
core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT); core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT);

View file

@ -156,8 +156,20 @@ async function run(): Promise<void> {
core.getBooleanInput('log-accepted-android-sdk-licenses') 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.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG)
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT) core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT)