Skip to content

Commit eb7920b

Browse files
Implement action input parameter 'packages'
1 parent a86cdbf commit eb7920b

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,21 @@ steps:
3939
```
4040
4141
## Additional packages
42-
By default, sdkmanager installs "tools" and "platform-tools" packages. To install additional packages, call sdkmanager manually:
42+
Input parameter `packages` controls which packages this action will install from Android SDK.
43+
44+
Default value is `tools platform-tools`, supply an empty string to skip installing additional packages.
45+
46+
Additional packages can be installed at a later time by calling sdkmanager manually.
47+
4348
```yaml
4449
- name: Setup Android SDK
4550
uses: android-actions/setup-android@v3
51+
with:
52+
packages: ''
53+
54+
# ...
4655
47-
- run: sdkmanager "ndk;26.1.10909125" "cmake;3.22.1"
56+
- run: sdkmanager tools platform-tools
4857
```
4958

5059
## SDK Version selection

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ inputs:
1818
required: false
1919
default: 'true'
2020

21+
packages:
22+
description: 'Additional packages to install'
23+
required: false
24+
default: 'tools platform-tools'
25+
2126
runs:
2227
using: node20
2328
main: 'dist/index.js'

dist/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28269,8 +28269,19 @@ function run() {
2826928269
core.info('Accepting Android SDK licenses');
2827028270
yield callSdkManager(sdkManagerExe, '--licenses', core.getBooleanInput('log-accepted-android-sdk-licenses'));
2827128271
}
28272-
yield callSdkManager(sdkManagerExe, 'tools');
28273-
yield callSdkManager(sdkManagerExe, 'platform-tools');
28272+
const packages = core
28273+
.getInput('packages', { required: false })
28274+
.split(' ')
28275+
.map(function (str) {
28276+
return str.trim();
28277+
})
28278+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
28279+
.filter(function (element, index, array) {
28280+
return element;
28281+
});
28282+
for (const pkg of packages) {
28283+
yield callSdkManager(sdkManagerExe, pkg);
28284+
}
2827428285
core.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG);
2827528286
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT);
2827628287
core.exportVariable('ANDROID_SDK_ROOT', ANDROID_SDK_ROOT);

src/main.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,20 @@ async function run(): Promise<void> {
156156
core.getBooleanInput('log-accepted-android-sdk-licenses')
157157
)
158158
}
159-
await callSdkManager(sdkManagerExe, 'tools')
160-
await callSdkManager(sdkManagerExe, 'platform-tools')
159+
160+
const packages = core
161+
.getInput('packages', {required: false})
162+
.split(' ')
163+
.map(function (str) {
164+
return str.trim()
165+
})
166+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
167+
.filter(function (element, index, array) {
168+
return element
169+
})
170+
for (const pkg of packages) {
171+
await callSdkManager(sdkManagerExe, pkg)
172+
}
161173

162174
core.setOutput('ANDROID_COMMANDLINE_TOOLS_VERSION', VERSION_LONG)
163175
core.exportVariable('ANDROID_HOME', ANDROID_SDK_ROOT)

0 commit comments

Comments
 (0)